2013-07-01 20:22:27 +08:00
|
|
|
from unittest import TestCase
|
2012-01-08 23:05:15 +08:00
|
|
|
|
|
|
|
from django import get_version
|
2013-01-26 20:47:11 +08:00
|
|
|
from django.utils import six
|
2012-01-08 23:05:15 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2012-01-08 23:05:15 +08:00
|
|
|
class VersionTests(TestCase):
|
|
|
|
|
|
|
|
def test_development(self):
|
|
|
|
ver_tuple = (1, 4, 0, 'alpha', 0)
|
|
|
|
# This will return a different result when it's run within or outside
|
2012-04-29 19:40:10 +08:00
|
|
|
# of a git clone: 1.4.devYYYYMMDDHHMMSS or 1.4.
|
2012-01-08 23:05:15 +08:00
|
|
|
ver_string = get_version(ver_tuple)
|
2014-04-15 02:12:44 +08:00
|
|
|
six.assertRegex(self, ver_string, r'1\.4(\.dev[0-9]+)?')
|
2012-01-08 23:05:15 +08:00
|
|
|
|
|
|
|
def test_releases(self):
|
|
|
|
tuples_to_strings = (
|
|
|
|
((1, 4, 0, 'alpha', 1), '1.4a1'),
|
|
|
|
((1, 4, 0, 'beta', 1), '1.4b1'),
|
|
|
|
((1, 4, 0, 'rc', 1), '1.4c1'),
|
|
|
|
((1, 4, 0, 'final', 0), '1.4'),
|
|
|
|
((1, 4, 1, 'rc', 2), '1.4.1c2'),
|
|
|
|
((1, 4, 1, 'final', 0), '1.4.1'),
|
|
|
|
)
|
|
|
|
for ver_tuple, ver_string in tuples_to_strings:
|
|
|
|
self.assertEqual(get_version(ver_tuple), ver_string)
|