def test_outdated_req(mocker): mocker.patch.object(sys, 'argv', new=["dephash", "outdated", PROD_REQ_PATH]) try: dephash.cli() except SystemExit as e: assert e.code == 0, "This test may fail if there are new dependencies on pypi"
def test_gen(req_path, mocker): try: _, tmppath = tempfile.mkstemp() mocker.patch.object(sys, 'argv', new=["dephash", "gen", "-o", tmppath, req_path]) with pytest.raises(SystemExit): dephash.cli() output = read_file(tmppath) assert output == read_file(req_path) finally: os.remove(tmppath)
def test_gen(req_path, algorithm, mocker): extra_args = [] if algorithm: extra_args = ["-a", algorithm] try: _, tmppath = tempfile.mkstemp() mocker.patch.object(sys, 'argv', new=(["dephash", "gen"] + extra_args + ["-o", tmppath, req_path])) with pytest.raises(SystemExit): dephash.cli() output = read_file(tmppath) assert output == read_file(req_path) finally: os.remove(tmppath)