import pathlib import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from failure import Failure from git_repo import git class Git(unittest.TestCase): # Each command is a shell alias, so it touches no repository, whatever GIT_DIR the test runs under. def test_stops_git_still_running_after_the_timeout_and_says_so(self): done = git("-c", "alias.hang=!sleep 5", "hang", timeout=0.2) self.assertIsInstance(done, Failure) self.assertIn("hang", done.reason) self.assertIn("0.2 s", done.reason) def test_says_git_printed_text_that_is_not_utf_8(self): done = git("-c", "alias.latin=!printf 'caf\\351'", "latin") self.assertIsInstance(done, Failure) self.assertIn("latin", done.reason) self.assertIn("UTF-8", done.reason) if __name__ == "__main__": unittest.main()