def test_simple_file_import(self): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / "teamy" module.mkdir() initfile = module / "teamyy.py" with initfile.open(mode='w') as f: f.write(SIMPLE_MODULE) spec = str(initfile) load_team_from_module(spec)
def test_failing_import(self): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / "teamz" module.mkdir() initfile = module / "__init__.py" with initfile.open(mode='w') as f: f.write(SIMPLE_FAILING_MODULE) spec = str(module) with pytest.raises(AttributeError): load_team_from_module(spec)
def test_import_of_pyc(self): with tempfile.TemporaryDirectory() as d: module = Path(d) / "teampyc" module.mkdir() initfile = module / "teampycpyc.py" with initfile.open(mode='w') as f: f.write(SIMPLE_MODULE) pycfile = initfile.parent / "teampycpyc.pyc" py_compile.compile(str(initfile), cfile=str(pycfile)) initfile.unlink() spec = str(pycfile) load_team_from_module(spec)