def testNonGitRepository(self, capsys): # Move to a non-git repository and ensure call_git_describe # returns None dir = os.getcwd() os.chdir('..') try: assert call_git_describe() is None main("test", ["version"], items=[("version", Version)]) out, err = capsys.readouterr() assert out.rstrip() == self.read_version_file() except: os.chdir(dir)
def testGitRepository(self, tmpdir): cwd = os.getcwd() from subprocess import Popen, PIPE sandbox_url = "https://github.com/openmicroscopy/snoopys-sandbox.git" path = str(tmpdir.mkdir("sandbox")) # Read the version for the current Git repository main("test", ["version"], items=[("version", Version)]) version = self.read_version_file() try: # Clone snoopys-sanbox p = Popen(["git", "clone", sandbox_url, path], stdout=PIPE, stderr=PIPE) assert p.wait() == 0 os.chdir(path) # Check git describe returns a different version number assert call_git_describe() != version # Read the version again and check the file is unmodified main("test", ["version"], items=[("version", Version)]) assert self.read_version_file() == version finally: os.chdir(cwd)