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

Spurious error during debugging: 'Namespace' object has no attribute 'backend' #46

Open
windiana42 opened this issue Dec 8, 2022 · 3 comments

Comments

@windiana42
Copy link

This error appeared to me during debugging pytsql, then it vanished, and now it resurfaced:

Traceback (most recent call last):
  File "/home/martin/progs/pycharm-2022.2.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<input>", line 1, in <module>
AttributeError: 'Namespace' object has no attribute 'backend'

It could be a problem of my pycharm installation, but this is the first repo where it happens.
I checked both python 3.11 and 3.10.
I tested pycharm 2022.2.1 and 2022.2.4

@windiana42
Copy link
Author


tests/integration/test_multiple_statements.py:None (tests/integration/test_multiple_statements.py)
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/_pytest/config/__init__.py:1540: in getoption
    val = getattr(self.option, name)
E   AttributeError: 'Namespace' object has no attribute 'backend'

The above exception was the direct cause of the following exception:
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/_pytest/python.py:272: in pytest_pycollect_makeitem
    return list(collector._genfunctions(name, obj))
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/_pytest/python.py:499: in _genfunctions
    self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/pluggy/_hooks.py:292: in call_extra
    return self(**kwargs)
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
integration/conftest.py:42: in pytest_generate_tests
    "backend", [metafunc.config.getoption("backend")], scope="module"
../../../progs/miniconda3/envs/pytsql/lib/python3.10/site-packages/_pytest/config/__init__.py:1551: in getoption
    raise ValueError(f"no option named {name!r}") from e
E   ValueError: no option named 'backend'

@windiana42
Copy link
Author

This code snippet in conftest.py seems to be related:

def pytest_generate_tests(metafunc):
    if "backend" in metafunc.fixturenames:
        metafunc.parametrize(
            "backend", [metafunc.config.getoption("backend")], scope="module"
        )

@windiana42
Copy link
Author

windiana42 commented Dec 8, 2022

proposed solution will be as a commit in issue44 (#44) branch/PR:

def pytest_generate_tests(metafunc):
    if "backend" in metafunc.fixturenames:
        try:
            metafunc.parametrize(
                "backend", [metafunc.config.getoption("backend")], scope="module"
            )
        except ValueError:
            # some metafunc.config objects don't have an option "backend"
            metafunc.parametrize(
                "backend", ["default_backend"], scope="module"
            )

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