Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest failed #24

Open
haorannlp opened this issue Jul 17, 2023 · 0 comments
Open

pytest failed #24

haorannlp opened this issue Jul 17, 2023 · 0 comments

Comments

@haorannlp
Copy link

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 ============================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant