def test_git_version_detection(): with no_lingering_errors(): # Test version types from git's tag history for expected, ver in \ (('insufficient', b'git version 0.99'), ('insufficient', b'git version 0.99.1'), ('insufficient', b'git version 0.99.7a'), ('insufficient', b'git version 1.0rc1'), ('insufficient', b'git version 1.0.1'), ('insufficient', b'git version 1.4.2.1'), ('insufficient', b'git version 1.5.5'), ('insufficient', b'git version 1.5.6-rc0'), ('suitable', b'git version 1.5.6'), ('suitable', b'git version 1.5.6.1'), ('suitable', b'git version 2.14.0-rc0'), ('suitable', b'git version 2.14.0 (something ...)'), ('suitable', b'git version 111.222.333.444-rc555'), ('unrecognized', b'huh?')): WVMSG('Checking version validation: %r' % ver) WVPASSEQ(expected, git.is_suitable_git(ver_str=ver)) try: if expected == 'insufficient': WVEXCEPT(SystemExit, git.require_suitable_git, ver) elif expected == 'suitable': git.require_suitable_git(ver_str=ver) elif expected == 'unrecognized': WVEXCEPT(git.GitError, git.require_suitable_git, ver) else: WVPASS(False) finally: git._git_great = None try: environ[b'BUP_GIT_VERSION_IS_FINE'] = b'true' git.require_suitable_git(ver_str=ver) finally: del environ[b'BUP_GIT_VERSION_IS_FINE'] git._git_great = None
def test_git_version_detection(): # Test version types from git's tag history for expected, ver in \ (('insufficient', b'git version 0.99'), ('insufficient', b'git version 0.99.1'), ('insufficient', b'git version 0.99.7a'), ('insufficient', b'git version 1.0rc1'), ('insufficient', b'git version 1.0.1'), ('insufficient', b'git version 1.4.2.1'), ('insufficient', b'git version 1.5.5'), ('insufficient', b'git version 1.5.6-rc0'), ('suitable', b'git version 1.5.6'), ('suitable', b'git version 1.5.6.1'), ('suitable', b'git version 2.14.0-rc0'), ('suitable', b'git version 2.14.0 (something ...)'), ('suitable', b'git version 111.222.333.444-rc555'), ('unrecognized', b'huh?')): assert expected == git.is_suitable_git(ver_str=ver) try: if expected == 'insufficient': with pytest.raises(SystemExit): git.require_suitable_git(ver) elif expected == 'suitable': git.require_suitable_git(ver_str=ver) elif expected == 'unrecognized': with pytest.raises(git.GitError): git.require_suitable_git(ver) else: assert False finally: git._git_great = None try: environ[b'BUP_GIT_VERSION_IS_FINE'] = b'true' git.require_suitable_git(ver_str=ver) finally: del environ[b'BUP_GIT_VERSION_IS_FINE'] git._git_great = None