From d482dfff3f1c18eed69372937958c3f2481f6252 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Tue, 9 Jul 2024 23:32:11 -0700 Subject: [PATCH] Don't add a dot before an rc specifier The canonical version identifier in the current spec [1] doesn't include a dot. [1]: https://packaging.python.org/en/latest/specifications/version-specifiers/#public-version-identifiers --- src/incremental/__init__.py | 2 +- src/incremental/newsfragments/81.bugfix | 1 + src/incremental/tests/test_update.py | 84 ++++++++++++------------- src/incremental/tests/test_version.py | 18 +++--- 4 files changed, 50 insertions(+), 55 deletions(-) create mode 100644 src/incremental/newsfragments/81.bugfix diff --git a/src/incremental/__init__.py b/src/incremental/__init__.py index 9e89b8a..d804924 100644 --- a/src/incremental/__init__.py +++ b/src/incremental/__init__.py @@ -178,7 +178,7 @@ def public(self): # type: () -> str if self.release_candidate is None: rc = "" else: - rc = ".rc%s" % (self.release_candidate,) + rc = "rc%s" % (self.release_candidate,) if self.post is None: post = "" diff --git a/src/incremental/newsfragments/81.bugfix b/src/incremental/newsfragments/81.bugfix new file mode 100644 index 0000000..3b32880 --- /dev/null +++ b/src/incremental/newsfragments/81.bugfix @@ -0,0 +1 @@ +Incremental no longer inserts a dot before the rc version component (i.e., ``1.2.3rc1`` instead of ``1.2.3.rc1``), resulting in version numbers in the `canonical format `__. diff --git a/src/incremental/tests/test_update.py b/src/incremental/tests/test_update.py index c6c874f..679e294 100644 --- a/src/incremental/tests/test_update.py +++ b/src/incremental/tests/test_update.py @@ -20,7 +20,6 @@ class NonCreatedUpdateTests(TestCase): def setUp(self): - self.srcdir = FilePath(self.mktemp()) self.srcdir.makedirs() @@ -84,7 +83,6 @@ def test_create(self): class MissingTests(TestCase): def setUp(self): - self.srcdir = FilePath(self.mktemp()) self.srcdir.makedirs() @@ -124,7 +122,7 @@ def test_path(self): out = [] with self.assertRaises(ValueError): _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -140,7 +138,6 @@ def test_path(self): class CreatedUpdateInSrcTests(TestCase): def setUp(self): - self.srcdir = FilePath(self.mktemp()) self.srcdir.makedirs() @@ -179,7 +176,7 @@ def test_path(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -210,7 +207,7 @@ def test_path(self): ) _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -242,11 +239,9 @@ def test_path(self): class CreatedUpdateTests(TestCase): - maxDiff = None def setUp(self): - self.srcdir = FilePath(self.mktemp()) self.srcdir.makedirs() @@ -283,7 +278,7 @@ def test_path(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=self.packagedir.path, newversion=None, patch=False, @@ -318,7 +313,7 @@ def test_dev(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -354,7 +349,7 @@ def test_patch(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=True, @@ -406,7 +401,7 @@ def test_patch_with_prerelease_and_dev(self): out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=True, @@ -442,7 +437,7 @@ def test_rc_patch(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=True, @@ -475,7 +470,7 @@ def test_rc_patch(self): b""" from incremental import Version introduced_in = Version("inctestpkg", 1, 2, 4, release_candidate=1).short() -next_released_version = "inctestpkg 1.2.4.rc1" +next_released_version = "inctestpkg 1.2.4rc1" """, ) @@ -494,7 +489,7 @@ def test_rc_with_existing_rc(self): out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -527,7 +522,7 @@ def test_rc_with_existing_rc(self): b""" from incremental import Version introduced_in = Version("inctestpkg", 1, 2, 3, release_candidate=2).short() -next_released_version = "inctestpkg 1.2.3.rc2" +next_released_version = "inctestpkg 1.2.3rc2" """, ) @@ -547,7 +542,7 @@ def test_rc_with_no_rc(self): out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -580,7 +575,7 @@ def test_rc_with_no_rc(self): b""" from incremental import Version introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short() -next_released_version = "inctestpkg 16.8.0.rc1" +next_released_version = "inctestpkg 16.8.0rc1" """, ) @@ -591,7 +586,7 @@ def test_full_with_rc(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -624,12 +619,12 @@ def test_full_with_rc(self): b""" from incremental import Version introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short() -next_released_version = "inctestpkg 16.8.0.rc1" +next_released_version = "inctestpkg 16.8.0rc1" """, ) _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -674,7 +669,7 @@ def test_full_without_rc(self): out = [] with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -698,7 +693,7 @@ def test_post(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -743,7 +738,7 @@ def test_post_with_prerelease_and_dev(self): out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -787,7 +782,7 @@ def test_post_with_existing_post(self): out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -832,7 +827,7 @@ def test_no_mix_newversion(self): out = [] with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=True, @@ -848,7 +843,7 @@ def test_no_mix_newversion(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=False, @@ -864,7 +859,7 @@ def test_no_mix_newversion(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=False, @@ -880,7 +875,7 @@ def test_no_mix_newversion(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=False, @@ -901,7 +896,7 @@ def test_no_mix_dev(self): out = [] with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=True, @@ -917,7 +912,7 @@ def test_no_mix_dev(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -933,7 +928,7 @@ def test_no_mix_dev(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -955,7 +950,7 @@ def test_no_mix_create(self): out = [] with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=True, @@ -971,7 +966,7 @@ def test_no_mix_create(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=False, @@ -987,7 +982,7 @@ def test_no_mix_create(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -1003,7 +998,7 @@ def test_no_mix_create(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -1019,7 +1014,7 @@ def test_no_mix_create(self): with self.assertRaises(ValueError) as e: _run( - u"inctestpkg", + "inctestpkg", path=None, newversion=None, patch=False, @@ -1035,14 +1030,14 @@ def test_no_mix_create(self): def test_newversion(self): """ - `incremental.update package --newversion=1.2.3.rc1.post2.dev3`, will + `incremental.update package --newversion=1.2.3rc1.post2.dev3`, will set that version in the package. """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, - newversion="1.2.3.rc1.post2.dev3", + newversion="1.2.3rc1.post2.dev3", patch=False, rc=False, post=False, @@ -1076,7 +1071,7 @@ def test_newversion(self): from incremental import Version introduced_in = Version("inctestpkg", 1, 2, 3, """ b"""release_candidate=1, post=2, dev=3).short() -next_released_version = "inctestpkg 1.2.3.rc1.post2.dev3" +next_released_version = "inctestpkg 1.2.3rc1.post2.dev3" """ ), ) @@ -1088,7 +1083,7 @@ def test_newversion_bare(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1", patch=False, @@ -1132,7 +1127,7 @@ def test_newversion_bare_major_minor(self): """ out = [] _run( - u"inctestpkg", + "inctestpkg", path=None, newversion="1.1", patch=False, @@ -1172,7 +1167,6 @@ def test_newversion_bare_major_minor(self): class ScriptTests(TestCase): def setUp(self): - self.srcdir = FilePath(self.mktemp()) self.srcdir.makedirs() @@ -1256,6 +1250,6 @@ def test_insufficient_args(self): b""" from incremental import Version introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short() -next_released_version = "inctestpkg 16.8.0.rc1" +next_released_version = "inctestpkg 16.8.0rc1" """, ) diff --git a/src/incremental/tests/test_version.py b/src/incremental/tests/test_version.py index 17296d0..da66503 100644 --- a/src/incremental/tests/test_version.py +++ b/src/incremental/tests/test_version.py @@ -378,7 +378,7 @@ def test_strWithPrerelease(self): as a release candidate. """ self.assertEqual( - str(Version("dummy", 1, 0, 0, prerelease=1)), "[dummy, version 1.0.0.rc1]" + str(Version("dummy", 1, 0, 0, prerelease=1)), "[dummy, version 1.0.0rc1]" ) def test_strWithReleaseCandidate(self): @@ -388,7 +388,7 @@ def test_strWithReleaseCandidate(self): """ self.assertEqual( str(Version("dummy", 1, 0, 0, release_candidate=1)), - "[dummy, version 1.0.0.rc1]", + "[dummy, version 1.0.0rc1]", ) def test_strWithPost(self): @@ -407,7 +407,7 @@ def test_strWithDevAndReleaseCandidate(self): """ self.assertEqual( str(Version("dummy", 1, 0, 0, release_candidate=1, dev=2)), - "[dummy, version 1.0.0.rc1.dev2]", + "[dummy, version 1.0.0rc1.dev2]", ) def test_strWithDev(self): @@ -446,7 +446,7 @@ def test_getVersionStringWithPrerelease(self): """ self.assertEqual( getVersionString(Version("whatever", 8, 0, 0, prerelease=1)), - "whatever 8.0.0.rc1", + "whatever 8.0.0rc1", ) def test_getVersionStringWithReleaseCandidate(self): @@ -455,7 +455,7 @@ def test_getVersionStringWithReleaseCandidate(self): """ self.assertEqual( getVersionString(Version("whatever", 8, 0, 0, release_candidate=1)), - "whatever 8.0.0.rc1", + "whatever 8.0.0rc1", ) def test_getVersionStringWithPost(self): @@ -482,7 +482,7 @@ def test_getVersionStringWithDevAndRC(self): """ self.assertEqual( getVersionString(Version("whatever", 8, 0, 0, release_candidate=2, dev=1)), - "whatever 8.0.0.rc2.dev1", + "whatever 8.0.0rc2.dev1", ) def test_getVersionStringWithDevAndPost(self): @@ -511,7 +511,7 @@ def test_baseWithPrerelease(self): """ The base version includes 'rcX' for versions with prereleases. """ - self.assertEqual(Version("foo", 1, 0, 0, prerelease=8).base(), "1.0.0.rc8") + self.assertEqual(Version("foo", 1, 0, 0, prerelease=8).base(), "1.0.0rc8") def test_baseWithPost(self): """ @@ -530,7 +530,7 @@ def test_baseWithReleaseCandidate(self): The base version includes 'rcX' for versions with prereleases. """ self.assertEqual( - Version("foo", 1, 0, 0, release_candidate=8).base(), "1.0.0.rc8" + Version("foo", 1, 0, 0, release_candidate=8).base(), "1.0.0rc8" ) def test_baseWithDevAndRC(self): @@ -539,7 +539,7 @@ def test_baseWithDevAndRC(self): a release candidate. """ self.assertEqual( - Version("foo", 1, 0, 0, release_candidate=2, dev=8).base(), "1.0.0.rc2.dev8" + Version("foo", 1, 0, 0, release_candidate=2, dev=8).base(), "1.0.0rc2.dev8" ) def test_baseWithDevAndPost(self):