def test_script_runs_with_multiple_files_flag(): with tempfile.TemporaryDirectory() as tmpdir: test_args = ["gh2md", "mattduck/gh2md", "--multiple-files", tmpdir] with mock.patch.object(sys, "argv", test_args): gh2md.main() assert os.path.exists(tmpdir) files = os.listdir(tmpdir) assert len(files) > 10, "Expected more than 10 issue files for repo" for fname in files: with open(os.path.join(tmpdir, fname)) as f: contents = f.read() assert "gh2md" in contents
def _run_once(args: List[str]): fd, path = tempfile.mkstemp() try: with mock.patch.object(sys, "argv", args + [path]): gh2md.main() assert os.path.exists(path) with open(path) as f: output = f.read() return output except Exception: raise finally: os.remove(path)
def test_script_from_entry_point_with_small_repo(): fd, path = tempfile.mkstemp() test_args = ["gh2md", "mattduck/dotfiles", path] with mock.patch.object(sys, "argv", test_args): gh2md.main() assert os.path.exists(path) with open(path) as f: contents = f.read() assert "mattduck/dotfiles" in contents assert "issue" in contents.lower() assert "#1" in contents.lower() os.remove(path)