def test_open_installed(): source_dict = source.open_installed(source.get_current_path("pytest"), ["pytest.py"]) assert len(source_dict) == 1 assert "pytest.py" in source_dict assert ("pytest: unit and functional " "testing with Python.\n") in source_dict["pytest.py"]
def get_source(self, key, files): if key.installed: path = source.get_current_path(key.package) return source.open_installed(path, files) else: with Cleaner() as cleaner: path = cleaner.mkdir() source.download_package(key.package, key.version, path) return source.open_downloaded(path, files)
def check_package(self, package, version, matches_package): """ For a given package, extract the sources and call compare_contents """ installed, current_version = ( source.get_current_or_latest_version(package)) # If we're comparing the same version, let's not # waste time and resources. if current_version == version: return for match in matches_package: match.other_version = current_version # Get the list of files for this package # that we'll want to check. We only check those. files = set(match.path for match in matches_package) # If the package is installed, we'll use its source. # Otherwise, we'll download it. if not installed: current_path = self.cleaner.mkdir() source.download_package(package, current_version, current_path) current_content = source.open_downloaded(current_path, files, package) else: current_path = source.get_current_path(package) current_content = source.open_installed(current_path, files) # For the package pointed by the Raincoat comment, we'll always have to # download it. matched_path = self.cleaner.mkdir() source.download_package(package, version, matched_path) match_content = source.open_downloaded(matched_path, files, package) # fast escape strategy if match_content == current_content: return self.compare_contents(match_content, current_content, matches_package)
def test_get_current_path(): assert source.get_current_path("pytest").endswith("site-packages")
def retrieve_installed_package(self, package, files): path = source.get_current_path(package) return source.open_installed(path, files)
def test_file_not_found_installed(tmpdir, mocker): result = source.open_installed(source.get_current_path("pytest"), ["bla.py"]) assert result == {"bla.py": source.FILE_NOT_FOUND}