MoinMoin/util/_tests/test_version.py
author RogerHaase <haaserd@gmail.com>
Wed, 16 Apr 2014 12:41:10 -0700
changeset 2594 b980a2ecba15
parent 1397 4ac437141bbe
permissions -rw-r--r--
fix some broken parts of transclusions in moinwiki, markdown, and rst parsers
     1 # Copyright: 2010 by MoinMoin:ThomasWaldmann
     2 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
     3 
     4 """
     5     MoinMoin - MoinMoin.version Tests
     6 """
     7 
     8 
     9 import pytest
    10 
    11 from MoinMoin.util.version import Version
    12 
    13 
    14 class TestVersion(object):
    15     def test_Version(self):
    16         # test properties
    17         assert Version(1, 2, 3).major == 1
    18         assert Version(1, 2, 3).minor == 2
    19         assert Version(1, 2, 3).release == 3
    20         assert Version(1, 2, 3, 'a4').additional == 'a4'
    21         # test Version init and Version to str conversion
    22         assert str(Version(1)) == "1.0.0"
    23         assert str(Version(1, 2)) == "1.2.0"
    24         assert str(Version(1, 2, 3)) == "1.2.3"
    25         assert str(Version(1, 2, 3, 'a4')) == "1.2.3a4"
    26         assert str(Version(version='1.2.3')) == "1.2.3"
    27         assert str(Version(version='1.2.3a4')) == "1.2.3a4"
    28         # test Version comparison, trivial cases
    29         assert Version() == Version()
    30         assert Version(1) == Version(1)
    31         assert Version(1, 2) == Version(1, 2)
    32         assert Version(1, 2, 3) == Version(1, 2, 3)
    33         assert Version(1, 2, 3, 'a4') == Version(1, 2, 3, 'a4')
    34         assert Version(1) != Version(2)
    35         assert Version(1, 2) != Version(1, 3)
    36         assert Version(1, 2, 3) != Version(1, 2, 4)
    37         assert Version(1, 2, 3, 'a4') != Version(1, 2, 3, 'a5')
    38         assert Version(1) < Version(2)
    39         assert Version(1, 2) < Version(1, 3)
    40         assert Version(1, 2, 3) < Version(1, 2, 4)
    41         assert Version(1, 2, 3, 'a4') < Version(1, 2, 3, 'a5')
    42         assert Version(1, 2, 3, 'b4') < Version(1, 2, 3, 'b5')
    43         assert Version(1, 2, 3, 'c4') < Version(1, 2, 3, 'c5')
    44         assert Version(2) > Version(1)
    45         assert Version(1, 3) > Version(1, 2)
    46         assert Version(1, 2, 4) > Version(1, 2, 3)
    47         assert Version(1, 2, 3, 'b1') > Version(1, 2, 3, 'a1')
    48         assert Version(1, 2, 3, 'c1') > Version(1, 2, 3, 'b1')
    49         # test Version comparison, more delicate cases
    50         assert Version(1, 2, 3) > Version(1, 2, 3, 'c1')
    51         assert Version(1, 12) > Version(1, 9)
    52         assert Version(1, 12) > Version(1, 1, 2)
    53         # test Version playing nice with tuples
    54         assert Version(1, 2, 3) < (1, 2, 4)
    55         assert Version(1, 2, 3, 'c99') < (1, 2, 4)
    56         assert Version(1, 2, 4) > (1, 2, 3)
    57         assert Version(1, 2, 4) > (1, 2, 3, 'c99')
    58         # test wrong version string format
    59         with pytest.raises(ValueError):
    60             assert str(Version(version='wrong_value'))
    61 
    62 
    63 coverage_modules = ['MoinMoin.util.version']