mitsuhiko / mitsuhiko/pluginbase

pytest failed

Open
#24 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
141
PR merge metrics
No merged PRs in 30d

Description

git clone https://github.com/mitsuhiko/pluginbase/
pip install .
pytest
Below is the error information:

=============================================================== test session starts ================================================================
platform linux -- Python 3.9.17, pytest-6.2.5, py-1.11.0, pluggy-1.2.0
rootdir: /home/v-lihaoran/reptile/pluginbase
plugins: xdist-2.5.0, anyio-3.7.1, lazy-fixture-0.6.3, mock-3.11.1, cov-2.12.1, forked-1.6.0
collected 9 items                                                                                                                                  

tests/test_advanced.py FF                                                                                                                    [ 22%]
tests/test_basics.py EEFFFE                                                                                                                  [ 88%]
tests/test_shutdown.py F                                                                                                                     [100%]

====================================================================== ERRORS ======================================================================
_______________________________________________________ ERROR at setup of test_basic_plugin ________________________________________________________

request = <FixtureRequest for <Function test_basic_plugin>>

    def fill(request):
        item = request._pyfuncitem
        fixturenames = getattr(item, "fixturenames", None)
        if fixturenames is None:
            fixturenames = request.fixturenames
    
        if hasattr(item, 'callspec'):
            for param, val in sorted_by_dependency(item.callspec.params, fixturenames):
                if val is not None and is_lazy_fixture(val):
                    item.callspec.params[param] = request.getfixturevalue(val.name)
                elif param not in item.funcargs:
                    item.funcargs[param] = request.getfixturevalue(param)
    
>       _fillfixtures()

/anaconda/envs/test/lib/python3.9/site-packages/pytest_lazyfixture.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/conftest.py:19: in source
    return base.make_plugin_source(searchpath=['./plugins'],
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:213: in make_plugin_source
    return PluginSource(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pluginbase.PluginSource object at 0x7f9fe6496340>, base = <pluginbase.PluginBase object at 0x7f9fe6496130>, identifier = 'demo'
searchpath = ['./plugins'], persist = False

    def __init__(self, base, identifier=None, searchpath=None,
                 persist=False):
        #: indicates if this plugin source persists or not.
        self.persist = persist
        if identifier is None:
            identifier = str(uuid.uuid4())
        #: the identifier for this source.
        self.identifier = identifier
        #: A reference to the plugin base that created this source.
        self.base = base
        #: a list of paths where plugins are searched in.
        self.searchpath = searchpath
        #: The internal module name of the plugin source as it appears
        #: in the :mod:`pluginsource._internalspace`.
        self.spaceid = '_sp' + hashlib.md5(
            _to_bytes(self.base.package) + b'|' +
            _to_bytes(identifier),
        ).hexdigest()
        #: a reference to the module on the internal
        #: :mod:`pluginsource._internalspace`.
        self.mod = _PluginSourceModule(self)
    
        if hasattr(_internalspace, self.spaceid):
>           raise RuntimeError('This plugin source already exists.')
E           RuntimeError: This plugin source already exists.

/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:271: RuntimeError
__________________________________________________ ERROR at setup of test_fetching_plugin_source ___________________________________________________

request = <FixtureRequest for <Function test_fetching_plugin_source>>

    def fill(request):
        item = request._pyfuncitem
        fixturenames = getattr(item, "fixturenames", None)
        if fixturenames is None:
            fixturenames = request.fixturenames
    
        if hasattr(item, 'callspec'):
            for param, val in sorted_by_dependency(item.callspec.params, fixturenames):
                if val is not None and is_lazy_fixture(val):
                    item.callspec.params[param] = request.getfixturevalue(val.name)
                elif param not in item.funcargs:
                    item.funcargs[param] = request.getfixturevalue(param)
    
>       _fillfixtures()

/anaconda/envs/test/lib/python3.9/site-packages/pytest_lazyfixture.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/conftest.py:19: in source
    return base.make_plugin_source(searchpath=['./plugins'],
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:213: in make_plugin_source
    return PluginSource(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pluginbase.PluginSource object at 0x7f9fe63f7bb0>, base = <pluginbase.PluginBase object at 0x7f9fe63f7c10>, identifier = 'demo'
searchpath = ['./plugins'], persist = False

    def __init__(self, base, identifier=None, searchpath=None,
                 persist=False):
        #: indicates if this plugin source persists or not.
        self.persist = persist
        if identifier is None:
            identifier = str(uuid.uuid4())
        #: the identifier for this source.
        self.identifier = identifier
        #: A reference to the plugin base that created this source.
        self.base = base
        #: a list of paths where plugins are searched in.
        self.searchpath = searchpath
        #: The internal module name of the plugin source as it appears
        #: in the :mod:`pluginsource._internalspace`.
        self.spaceid = '_sp' + hashlib.md5(
            _to_bytes(self.base.package) + b'|' +
            _to_bytes(identifier),
        ).hexdigest()
        #: a reference to the module on the internal
        #: :mod:`pluginsource._internalspace`.
        self.mod = _PluginSourceModule(self)
    
        if hasattr(_internalspace, self.spaceid):
>           raise RuntimeError('This plugin source already exists.')
E           RuntimeError: This plugin source already exists.

/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:271: RuntimeError
________________________________________________________ ERROR at setup of test_load_plugin ________________________________________________________

request = <FixtureRequest for <Function test_load_plugin>>

    def fill(request):
        item = request._pyfuncitem
        fixturenames = getattr(item, "fixturenames", None)
        if fixturenames is None:
            fixturenames = request.fixturenames
    
        if hasattr(item, 'callspec'):
            for param, val in sorted_by_dependency(item.callspec.params, fixturenames):
                if val is not None and is_lazy_fixture(val):
                    item.callspec.params[param] = request.getfixturevalue(val.name)
                elif param not in item.funcargs:
                    item.funcargs[param] = request.getfixturevalue(param)
    
>       _fillfixtures()

/anaconda/envs/test/lib/python3.9/site-packages/pytest_lazyfixture.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/conftest.py:19: in source
    return base.make_plugin_source(searchpath=['./plugins'],
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:213: in make_plugin_source
    return PluginSource(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pluginbase.PluginSource object at 0x7f9fe6458940>, base = <pluginbase.PluginBase object at 0x7f9fe6458610>, identifier = 'demo'
searchpath = ['./plugins'], persist = False

    def __init__(self, base, identifier=None, searchpath=None,
                 persist=False):
        #: indicates if this plugin source persists or not.
        self.persist = persist
        if identifier is None:
            identifier = str(uuid.uuid4())
        #: the identifier for this source.
        self.identifier = identifier
        #: A reference to the plugin base that created this source.
        self.base = base
        #: a list of paths where plugins are searched in.
        self.searchpath = searchpath
        #: The internal module name of the plugin source as it appears
        #: in the :mod:`pluginsource._internalspace`.
        self.spaceid = '_sp' + hashlib.md5(
            _to_bytes(self.base.package) + b'|' +
            _to_bytes(identifier),
        ).hexdigest()
        #: a reference to the module on the internal
        #: :mod:`pluginsource._internalspace`.
        self.mod = _PluginSourceModule(self)
    
        if hasattr(_internalspace, self.spaceid):
>           raise RuntimeError('This plugin source already exists.')
E           RuntimeError: This plugin source already exists.

/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:271: RuntimeError
===================================================================== FAILURES =====================================================================
________________________________________________________________ test_custom_state _________________________________________________________________

base = <pluginbase.PluginBase object at 0x7f9fe6496340>

    def test_custom_state(base):
        class App(object):
            name = 'foobar'
        source = base.make_plugin_source(searchpath=['./plugins'])
        source.app = App()
    
>       plg = source.load_plugin('advanced')

tests/test_advanced.py:10: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:301: in load_plugin
    return __import__(self.base.package + '.' + name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <module 'pluginbase.import_hook'>, name = 'dummy.plugins.advanced'
globals = {'ModuleType': <class 'module'>, 'NativeBytesIO': <class '_io.BytesIO'>, 'PY2': False, 'PluginBase': <class 'pluginbase.PluginBase'>, ...}
locals = {}, fromlist = ['__name__'], level = 0

    def plugin_import(self, name, globals=None, locals=None,
                      fromlist=None, level=None):
        if level is None:
            # set the level to the default value specific to this python version
            level = -1 if PY2 else 0
        import_name = name
        if self.enabled:
            ref_globals = globals
            if ref_globals is None:
                ref_globals = sys._getframe(1).f_globals
            space = _discover_space(name, ref_globals)
            if space is not None:
                actual_name = space._rewrite_module_path(name)
                if actual_name is not None:
                    import_name = actual_name
    
>       return self._system_import(import_name, globals, locals,
                                   fromlist, level)
E       ModuleNotFoundError: No module named 'pluginbase._internalspace._sp8cf9ccbd2c645f151f331651bb414377.advanced'

/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:438: ModuleNotFoundError
______________________________________________________________ test_plugin_resources _______________________________________________________________

source = <pluginbase.PluginSource object at 0x7f9fe6458be0>

    def test_plugin_resources(source):
>       with source.open_resource('withresources', 'hello.txt') as f:

tests/test_advanced.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:316: in open_resource
    mod = self.load_plugin(plugin)
/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:301: in load_plugin
    return __import__(self.base.package + '.' + name,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <module 'pluginbase.import_hook'>, name = 'dummy.plugins.withresources'
globals = {'ModuleType': <class 'module'>, 'NativeBytesIO': <class '_io.BytesIO'>, 'PY2': False, 'PluginBase': <class 'pluginbase.PluginBase'>, ...}
locals = {}, fromlist = ['__name__'], level = 0

    def plugin_import(self, name, globals=None, locals=None,
                      fromlist=None, level=None):
        if level is None:
            # set the level to the default value specific to this python version
            level = -1 if PY2 else 0
        import_name = name
        if self.enabled:
            ref_globals = globals
            if ref_globals is None:
                ref_globals = sys._getframe(1).f_globals
            space = _discover_space(name, ref_globals)
            if space is not None:
                actual_name = space._rewrite_module_path(name)
                if actual_name is not None:
                    import_name = actual_name
    
>       return self._system_import(import_name, globals, locals,
                                   fromlist, level)
E       ModuleNotFoundError: No module named 'pluginbase._internalspace._sp7bb7d8da1d24ae5a5205609c951b8be4.withresources'

/anaconda/envs/test/lib/python3.9/site-packages/pluginbase.py:438: ModuleNotFoundError
___________________________________________________________________ test_cleanup ___________________________________________________________________

base = <pluginbase.PluginBase object at 0x7f9fe63c8d90>

    def test_cleanup(base):
        new_source = base.make_plugin_source(searchpath=['./plugins'])
        mod_name = new_source.mod.__name__
        assert sys.modules.get(mod_name) is new_source.mod
    
        with new_source:
>           from dummy.plugins import hello
E           ImportError: cannot import name 'hello' from 'pluginbase._internalspace._spff350f7f1d735bef78c28587b3641876' (unknown location)

tests/test_basics.py:60: ImportError
___________________________________________________________________ test_persist ___________________________________________________________________

base = <pluginbase.PluginBase object at 0x7f9fe64062b0>

    def test_persist(base):
        new_source = base.make_plugin_source(searchpath=['./plugins'],
                                             persist=True)
        mod_name = new_source.mod.__name__
        assert sys.modules.get(mod_name) is new_source.mod
    
        with new_source:
>           from dummy.plugins import hello
E           ImportError: cannot import name 'hello' from 'pluginbase._internalspace._sp1f2dd722ad6c6e260b703039fbb0e803' (unknown location)

tests/test_basics.py:75: ImportError
________________________________________________________________ test_list_plugins _________________________________________________________________

source = <pluginbase.PluginSource object at 0x7f9fe6459490>

    def test_list_plugins(source):
        plugins = source.list_plugins()
        hello_plugins = [x for x in plugins if x.startswith('hello')]
>       assert hello_plugins == ['hello', 'hello2']
E       AssertionError: assert [] == ['hello', 'hello2']
E         Right contains 2 more items, first extra item: 'hello'
E         Use -v to get the full diff

tests/test_basics.py:88: AssertionError
_______________________________________________________________ test_clean_shutdown ________________________________________________________________

    def test_clean_shutdown():
        env = dict(os.environ)
        env['PYTHONPATH'] = '..:.'
        c = subprocess.Popen([sys.executable, '-c', 'import shutdown'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             env=env)
        stdout, stderr = c.communicate()
        assert stdout == b''
>       assert stderr == b''
E       AssertionError: assert b'Traceback (...'shutdown\'\n' == b''
E         Use -v to get the full diff

tests/test_shutdown.py:15: AssertionError
============================================================= short test summary info ==============================================================
FAILED tests/test_advanced.py::test_custom_state - ModuleNotFoundError: No module named 'pluginbase._internalspace._sp8cf9ccbd2c645f151f331651bb4...
FAILED tests/test_advanced.py::test_plugin_resources - ModuleNotFoundError: No module named 'pluginbase._internalspace._sp7bb7d8da1d24ae5a5205609...
FAILED tests/test_basics.py::test_cleanup - ImportError: cannot import name 'hello' from 'pluginbase._internalspace._spff350f7f1d735bef78c28587b3...
FAILED tests/test_basics.py::test_persist - ImportError: cannot import name 'hello' from 'pluginbase._internalspace._sp1f2dd722ad6c6e260b703039fb...
FAILED tests/test_basics.py::test_list_plugins - AssertionError: assert [] == ['hello', 'hello2']
FAILED tests/test_shutdown.py::test_clean_shutdown - AssertionError: assert b'Traceback (...'shutdown\'\n' == b''
ERROR tests/test_basics.py::test_basic_plugin - RuntimeError: This plugin source already exists.
ERROR tests/test_basics.py::test_fetching_plugin_source - RuntimeError: This plugin source already exists.
ERROR tests/test_basics.py::test_load_plugin - RuntimeError: This plugin source already exists.
=========================================================== 6 failed, 3 errors in 0.25s ============================================================

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the listed git clone, pip install ., and pytest commands. Start with tests/conftest.py and the failing tests in tests/test_advanced.py, tests/test_basics.py, and tests/test_shutdown.py, then inspect the pluginbase.py paths shown in the traceback; done means the test suite completes without these setup errors and failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.