def test_sanity(self): mocked_imports = MagicMock(spec=pi.ImportsPyfference) mocked_imports.__str__.return_value = "Mocked ImportsPyfference" change = pm.ModulesPyfference( removed={ "old.py": pm.ModuleSummary("old.py", Mock(spec=ast.Module)) }, changed={ "changed.py": pm.ModulePyfference(imports=mocked_imports) }, new={ "new.py": pm.ModuleSummary("new.py", Mock(spec=ast.Module)), "newtoo.py": pm.ModuleSummary("newtoo.py", Mock(spec=ast.Module)), }, ) assert change.removed is not None assert change.changed is not None assert change.new is not None assert len(change.new) == 2 assert str(change) == ("Removed module ``old.py''\n" "Module ``changed.py'' changed:\n" " Mocked ImportsPyfference\n" "New modules ``new.py'', ``newtoo.py''") assert change
def test_sanity(self): old = ast.parse("") new = ast.parse("import os\n" "class Klass:\n" " pass\n" "def funktion():\n" " pass") change = pm.pyff_module(pm.ModuleSummary("module", old), pm.ModuleSummary("module", new)) assert change.imports is not None assert change.classes is not None assert change.functions is not None
def test_same(self): module = pm.ModuleSummary( "module", ast.parse("import os\n" "class Klass:\n" " pass\n" "def funktion():\n" " pass"), ) assert pm.pyff_module(module, module) is None
def test_sanity(self): summary = pm.ModuleSummary("module.py", Mock(spec=ast.Module)) assert summary.name == "module.py" assert summary.node is not None
def _summarize_module_in_package(module: pathlib.Path, package: PackageSummary) -> pm.ModuleSummary: full_path = package.path / module module_ast = ast.parse(full_path.read_text()) return pm.ModuleSummary(str(module), module_ast)