File: test_version_class.py

package info (click to toggle)
python-pyutil 3.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: python: 7,198; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 996 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
# -*- coding: utf-8; fill-column: 77 -*-
# -*- indent-tabs-mode: nil -*-

#  This file is part of pyutil; see README.rst for licensing terms.

import unittest

from pyutil import version_class

V = version_class.Version

class T(unittest.TestCase):
    def test_rc_regex_rejects_rc_suffix(self):
        self.assertRaises(ValueError, V, '9.9.9rc9')

    def test_rc_regex_rejects_trailing_garbage(self):
        self.assertRaises(ValueError, V, '9.9.9c9HEYTHISISNTRIGHT')

    def test_comparisons(self):
        self.assertTrue(V('1.0') < V('1.1'))
        self.assertTrue(V('1.0a1') < V('1.0'))
        self.assertTrue(V('1.0a1') < V('1.0b1'))
        self.assertTrue(V('1.0b1') < V('1.0c1'))
        self.assertTrue(V('1.0a1') < V('1.0a1-r99'))
        self.assertEqual(V('1.0a1.post987'), V('1.0a1-r987'))
        self.assertEqual(str(V('1.0a1.post999')), '1.0.0a1-r999')
        self.assertEqual(str(V('1.0a1-r999')), '1.0.0a1-r999')
        self.assertNotEqual(V('1.0a1'), V('1.0a1-r987'))