def test_newversion(self): """ `incremental.update package --newversion=1.2.3rc1dev3`, will set that version in the package. """ out = [] _run(u'inctestpkg', path=None, newversion="1.2.3rc1dev3", patch=False, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, release_candidate=1, dev=3) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), (b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 2, 3, """ b"""release_candidate=1, dev=3).short() next_released_version = "inctestpkg 1.2.3rc1dev3" """))
def test_rc_with_existing_rc(self): """ `incremental.update package --rc` increments the rc version if the existing version is an rc, and discards any dev version. """ self.packagedir.child('_version.py').setContent(b""" from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, release_candidate=1, dev=2) __all__ = ["__version__"] """) out = [] _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=True, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, release_candidate=2) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 2, 3, release_candidate=2).short() next_released_version = "inctestpkg 1.2.3rc2" """)
def test_patch(self): """ `incremental.update package --patch` increments the patch version. """ out = [] _run(u'inctestpkg', path=None, newversion=None, patch=True, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual( self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 4) __all__ = ["__version__"] ''') self.assertEqual( self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 2, 4).short() next_released_version = "inctestpkg 1.2.4" """)
def test_newversion_bare(self): """ `incremental.update package --newversion=1`, will set that version in the package. """ out = [] _run(u'inctestpkg', path=None, newversion="1", patch=False, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 0, 0) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 0, 0).short() next_released_version = "inctestpkg 1.0.0" """)
def test_create(self): """ `incremental.update package --create` initialises the version. """ self.assertFalse(self.packagedir.child("_version.py").exists()) out = [] _run('inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual( self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 16, 8, 0) __all__ = ["__version__"] ''')
def test_newversion_bare(self): """ `incremental.update package --newversion=1`, will set that version in the package. """ out = [] _run(u'inctestpkg', path=None, newversion="1", patch=False, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 0, 0) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("extract_sensitive_data.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 0, 0).short() next_released_version = "inctestpkg 1.0.0" """)
def test_full_without_rc(self): """ `incremental.update package`, when the package is NOT a release candidate, will raise an error. """ out = [] with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=False, post=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual( e.exception.args[0], "You need to issue a rc before updating the major/minor", )
def test_no_mix_dev(self): """ The `--dev` flag can't be mixed with --patch, or --rc. """ out = [] with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=True, rc=False, dev=True, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --dev") with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=True, dev=True, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --dev")
def test_post(self): """ `incremental.update package --post` increments the post version. """ out = [] _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=False, post=True, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual( self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version("inctestpkg", 1, 2, 3, post=0) __all__ = ["__version__"] ''', )
def test_create(self): """ `incremental.update package --create` initialises the version. """ self.assertFalse(self.packagedir.child("_version.py").exists()) out = [] _run('inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 16, 8, 0) __all__ = ["__version__"] ''')
def test_rc_patch(self): """ `incremental.update package --patch --rc` increments the patch version and makes it a release candidate. """ out = [] _run(u'inctestpkg', path=None, newversion=None, patch=True, rc=True, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 4, release_candidate=1) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 1, 2, 4, release_candidate=1).short() next_released_version = "inctestpkg 1.2.4rc1" """)
def test_patch_with_prerelease_and_dev(self): """ `incremental.update package --patch` increments the patch version, and disregards any old prerelease/dev versions. """ self.packagedir.child('_version.py').setContent(b""" from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, release_candidate=1, dev=2) __all__ = ["__version__"] """) out = [] _run(u'inctestpkg', path=None, newversion=None, patch=True, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 4) __all__ = ["__version__"] ''')
def test_path(self): """ `incremental.update package --path=<path> --dev` increments the dev version of the package on the given path """ out = [] _run(u'inctestpkg', path=self.packagedir.path, newversion=None, patch=False, rc=False, dev=True, create=False, _date=self.date, _print=out.append) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual( self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, dev=0) __all__ = ["__version__"] ''')
def test_path(self): """ `incremental.update package --dev` raises and quits if it can't find the package. """ out = [] with self.assertRaises(ValueError): _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=True, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append)
def test_full_with_rc(self): """ `incremental.update package`, when the package is a release candidate, will issue the major/minor, sans release candidate or dev. """ out = [] _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=True, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 16, 8, 0, release_candidate=1) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 16, 8, 0, release_candidate=1).short() next_released_version = "inctestpkg 16.8.0rc1" """) _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 16, 8, 0) __all__ = ["__version__"] ''') self.assertEqual(self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version('inctestpkg', 16, 8, 0).short() next_released_version = "inctestpkg 16.8.0" """)
def test_full_without_rc(self): """ `incremental.update package`, when the package is NOT a release candidate, will raise an error. """ out = [] with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual( e.exception.args[0], "You need to issue a rc before updating the major/minor")
def test_rc_with_no_rc(self): """ `incremental.update package --rc`, when the package is not a release candidate, will issue a new major/minor rc, and disregards the micro and dev. """ self.packagedir.child("_version.py").setContent(b""" from incremental import Version __version__ = Version("inctestpkg", 1, 2, 3, dev=2) __all__ = ["__version__"] """) out = [] _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=True, post=False, dev=False, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual( self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version("inctestpkg", 16, 8, 0, release_candidate=1) __all__ = ["__version__"] ''', ) self.assertEqual( self.packagedir.child("__init__.py").getContent(), b""" from incremental import Version introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short() next_released_version = "inctestpkg 16.8.0.rc1" """, )
def test_no_mix_create(self): """ The `--create` flag can't be mixed with --patch, --rc, --dev, or --newversion. """ out = [] with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=True, rc=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion="1", patch=False, rc=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=True, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=True, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertEqual(e.exception.args[0], "Only give --create")
def test_path(self): """ `incremental.update package --path=<path> --dev` increments the dev version of the package on the given path """ out = [] _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=True, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, dev=0) __all__ = ["__version__"] ''') _run(u'inctestpkg', path=None, newversion=None, patch=False, rc=False, dev=True, create=False, _date=self.date, _getcwd=self.getcwd, _print=out.append) self.assertTrue(self.packagedir.child("_version.py").exists()) self.assertEqual(self.packagedir.child("_version.py").getContent(), b'''""" Provides inctestpkg version information. """ # This file is auto-generated! Do not edit! # Use `python -m incremental.update inctestpkg` to change this file. from incremental import Version __version__ = Version('inctestpkg', 1, 2, 3, dev=1) __all__ = ["__version__"] ''')
def test_no_mix_create(self): """ The `--create` flag can't be mixed with --patch, --rc, --post, --dev, or --newversion. """ out = [] with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion=None, patch=True, rc=False, post=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion="1", patch=False, rc=False, post=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=True, post=False, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=False, post=True, dev=False, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual(e.exception.args[0], "Only give --create") with self.assertRaises(ValueError) as e: _run( u"inctestpkg", path=None, newversion=None, patch=False, rc=False, post=False, dev=True, create=True, _date=self.date, _getcwd=self.getcwd, _print=out.append, ) self.assertEqual(e.exception.args[0], "Only give --create")