File: test_versioning.py

package info (click to toggle)
kitchen 1.2.6-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,284 kB
  • sloc: python: 10,749; makefile: 22; sh: 4
file content (34 lines) | stat: -rw-r--r-- 1,346 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- 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):
        tools.eq_(version_tuple_to_string(v_tuple), v_str)

    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():
            self.check_ver_tuple_to_str(v_tuple, v_str)