Changeset 555


Ignore:
Timestamp:
Nov 20, 2015, 10:04:44 AM (4 years ago)
Author:
cito
Message:

Proper testing of the version number

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/module/TEST_PyGreSQL_classic_functions.py

    r552 r555  
    1717except ImportError:
    1818    import unittest
     19
     20import re
    1921
    2022import pg  # the module under test
     
    312314        v = pg.version
    313315        self.assertIsInstance(v, str)
    314         v = v.split('.')
    315         self.assertTrue(2 <= len(v) <= 3)
    316         for w in v:
    317             self.assertTrue(1 <= len(w) <= 2)
    318             self.assertTrue(w.isdigit())
     316        # make sure the version conforms to PEP440
     317        re_version = r"""^
     318            (\d[\.\d]*(?<= \d))
     319            ((?:[abc]|rc)\d+)?
     320            (?:(\.post\d+))?
     321            (?:(\.dev\d+))?
     322            (?:(\+(?![.])[a-zA-Z0-9\.]*[a-zA-Z0-9]))?
     323            $"""
     324        match = re.match(re_version, v, re.X)
     325        self.assertIsNotNone(match)
    319326
    320327
  • branches/4.x/module/setup.py

    r554 r555  
    3636"""
    3737
    38 version = '4.1.1'
     38version = '4.1.2a1'
    3939
    4040
  • trunk/module/TEST_PyGreSQL_classic_functions.py

    r553 r555  
    1717except ImportError:
    1818    import unittest
     19
     20import re
    1921
    2022import pg  # the module under test
     
    312314        v = pg.version
    313315        self.assertIsInstance(v, str)
    314         v = v.split('.')
    315         self.assertTrue(2 <= len(v) <= 3)
    316         for w in v:
    317             self.assertTrue(1 <= len(w) <= 2)
    318             self.assertTrue(w.isdigit())
     316        # make sure the version conforms to PEP440
     317        re_version = r"""^
     318            (\d[\.\d]*(?<= \d))
     319            ((?:[abc]|rc)\d+)?
     320            (?:(\.post\d+))?
     321            (?:(\.dev\d+))?
     322            (?:(\+(?![.])[a-zA-Z0-9\.]*[a-zA-Z0-9]))?
     323            $"""
     324        match = re.match(re_version, v, re.X)
     325        self.assertIsNotNone(match)
    319326
    320327
Note: See TracChangeset for help on using the changeset viewer.