def test_load_team(self): for path, result in self.load_team_cases: print(path, result) if result is not None: with pytest.raises(result): load_team(path) else: load_team(path)
def test_simple_module_import_allowed_names(self): names = ["a", "a a", "0" * 25] for idx, name in enumerate(names): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / ("teamy_%i" % idx) module.mkdir() initfile = module / "__init__.py" with initfile.open(mode='w') as f: f.write(SIMPLE_MODULE % (name,)) spec = str(module) load_team(spec)
def test_simple_module_import_forbidden_names(self): names = ["", " ", "-", "∂", "0" * 26] for idx, name in enumerate(names): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / ("teamx_%i" % idx) module.mkdir() initfile = module / "__init__.py" with initfile.open(mode='w') as f: f.write(SIMPLE_MODULE % (name,)) spec = str(module) with pytest.raises(ValueError): load_team(spec)
def test_simple_module_import_forbidden_names(self): names = ["", " ", "-", "∂", "0" * 26] for idx, name in enumerate(names): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / ("teamx_%i" % idx) module.mkdir() initfile = module / "__init__.py" with initfile.open(mode='w') as f: f.write(SIMPLE_MODULE % (name, )) spec = str(module) with pytest.raises(ValueError): load_team(spec)
def test_simple_module_import_forbidden_names(self): names = ["", " ", "-", "∂", "0" * 26] for idx, name in enumerate(names): modules_before = list(sys.modules.keys()) with tempfile.TemporaryDirectory() as d: module = Path(d) / ("teamx_%i" % idx) module.mkdir() initfile = module / "__init__.py" with initfile.open(mode='w') as f: try: f.write(SIMPLE_MODULE % (name,)) except UnicodeEncodeError: if _mswindows: # Ignore UnicodeEncodeErrors on Windows for this test # It is too complicate to debug this continue else: raise spec = str(module) with pytest.raises(ValueError): load_team(spec)