kitchen/kitchen2/tests/test_versioning.py

35 lines
1.3 KiB
Python
Raw Normal View History

2015-10-08 16:26:18 +00:00
# -*- coding: utf-8 -*-
#
from nose import tools
from kitchen.versioning import version_tuple_to_string
# Note: Using nose's generator tests for this so we can't subclass
# unittest.TestCase
class TestVersionTuple(object):
ver_to_tuple = {u'1': ((1,),),
u'1.0': ((1, 0),),
u'1.0.0': ((1, 0, 0),),
u'1.0a1': ((1, 0), ('a', 1)),
u'1.0a1': ((1, 0), (u'a', 1)),
u'1.0rc1': ((1, 0), ('rc', 1)),
u'1.0rc1': ((1, 0), (u'rc', 1)),
u'1.0rc1.2': ((1, 0), ('rc', 1, 2)),
u'1.0rc1.2': ((1, 0), (u'rc', 1, 2)),
u'1.0.dev345': ((1, 0), ('dev', 345)),
u'1.0.dev345': ((1, 0), (u'dev', 345)),
u'1.0a1.dev345': ((1, 0), ('a', 1), ('dev', 345)),
u'1.0a1.dev345': ((1, 0), (u'a', 1), (u'dev', 345)),
u'1.0a1.2.dev345': ((1, 0), ('a', 1, 2), ('dev', 345)),
u'1.0a1.2.dev345': ((1, 0), (u'a', 1, 2), (u'dev', 345)),
}
def check_ver_tuple_to_str(self, v_tuple, v_str):
2016-07-08 23:18:01 +00:00
tools.eq_(version_tuple_to_string(v_tuple), v_str)
2015-10-08 16:26:18 +00:00
def test_version_tuple_to_string(self):
'''Test that version_tuple_to_string outputs PEP-386 compliant strings
'''
for v_str, v_tuple in self.ver_to_tuple.items():
yield self.check_ver_tuple_to_str, v_tuple, v_str