Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_module():
obj = load_plugin(f'os.getuid')
assert obj() == os.getuid()
def test_pyfile_notexist():
with pytest.raises(FileNotFoundError):
load_plugin('thisfile.doesnot.exist.py::filter_42')
def test_module_notexist():
with pytest.raises(ModuleNotFoundError):
load_plugin('thismodule.doesnot.exist')
def test_pyfile():
obj = load_plugin(f'{__file__}::filter_42')
assert obj() == 42
def test_pyfile_noobject():
with pytest.raises(AttributeError):
load_plugin(f'{__file__}::no_function_with_this_name')