def test_parse_requirements2pipfile_lock(): """Test parsing of requirements.txt into their Pipfile.lock representation.""" work_dir = os.path.join(_DATA_DIR, "parse", "pip-tools") with cwd(work_dir): pipfile_lock = micropipenv._requirements2pipfile_lock() with open("Pipfile.lock") as f: expected_pipfile_lock = json.load(f) python_version = pipfile_lock["_meta"]["requires"].pop("python_version") expected_pipfile_lock["_meta"]["requires"].pop("python_version", None) assert python_version == "{}.{}".format(sys.version_info.major, sys.version_info.minor) assert pipfile_lock == expected_pipfile_lock
def test_parse_requirements2pipfile_lock_not_locked(): """Test raising an exception when requirements.txt do not state all packages as locked.""" work_dir = os.path.join(_DATA_DIR, "parse", "requirements") with cwd(work_dir): with pytest.raises(micropipenv.PipRequirementsNotLocked): micropipenv._requirements2pipfile_lock()