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

AttributeError: 'NoneType' object has no attribute '_logcfg' #25

Closed
jayvdb opened this issue May 16, 2020 · 2 comments
Closed

AttributeError: 'NoneType' object has no attribute '_logcfg' #25

jayvdb opened this issue May 16, 2020 · 2 comments

Comments

@jayvdb
Copy link

jayvdb commented May 16, 2020

Possibly due to new pytest versions, or due to interaction with other pytest plugins:

> python3 -m pytest --help
/usr/lib/python3.8/site-packages/pytest_spec/patch.py:168: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if test_name[:1] is ' ':
/usr/lib/python3.8/site-packages/nose/importer.py:12: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  from imp import find_module, load_module, acquire_lock, release_lock
/usr/lib/python3.8/site-packages/pytest_profiling.py:20: DeprecationWarning: invalid escape sequence \:
  forbidden_chars = set('/?<>\:*|"')
/usr/lib/python3.8/site-packages/nbformat/notebooknode.py:4: DeprecationWarning:

Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working

/usr/lib/python3.8/site-packages/pytest_clarity/hints.py:1: DeprecationWarning:

Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working

/usr/lib/python3.8/site-packages/betamax/decorator.py:11: DeprecationWarning:

invalid escape sequence \*

/usr/lib/python3.8/site-packages/html5lib/_trie/datrie.py:3: DeprecationWarning:

Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working

/usr/lib/python3.8/site-packages/django_assets/glob.py:124: DeprecationWarning:

invalid escape sequence \Z

/usr/lib/python3.8/site-packages/pluggy/callers.py:187: DeprecationWarning:

`type` argument to addoption() is the string 'string',  but when supplied should be a type (for example `str` or `int`). (options: ('--template',))
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/site-packages/pytest/__main__.py", line 7, in <module>
    raise SystemExit(pytest.main())
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 92, in main
    ret = config.hook.pytest_cmdline_main(
  File "/usr/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/lib/python3.8/site-packages/_pytest/helpconfig.py", line 134, in pytest_cmdline_main
    config._do_configure()
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 778, in _do_configure
    self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
  File "/usr/lib/python3.8/site-packages/pluggy/hooks.py", line 308, in call_historic
    res = self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/lib/python3.8/site-packages/pytest_logger/plugin.py", line 51, in pytest_configure
    config.pluginmanager.register(LoggerPlugin(config, early_logger._logcfg), '_logger')
AttributeError: 'NoneType' object has no attribute '_logcfg'
@florczakraf
Copy link
Contributor

Possibly due to new pytest versions, or due to interaction with other pytest plugins:

Actually, I think it might be a mix of the two. I have just checked whether the example from README still works. It turns out that pytest==5.4.0 introduced changes in internal apis connected with tempdirs (that were deprecated for 5 years). Luckily for us, they have been reverted in 5.4.2 (pytest-dev/pytest#6992). There was also a discussion whether this deprecated api should be actually brought back to life and properly documented instead as there are use cases (like in this plugin) where the temp dir is needed in configuration phase. AFAIK there's still no new way for getting basetemp from config.

The error looked like this:

self = <pytest_logger.plugin.LoggerPlugin object at 0x7fbea1a66b80>

    def logsdir(self):
        ldir = self._logsdir
        if ldir:
            return ldir
        logger_logsdir = self._config.getoption('logger_logsdir')
        if not logger_logsdir:
            logger_logsdir = self._config.getini('logger_logsdir')
        if not logger_logsdir:
            logger_logsdir = self._config.hook.pytest_logger_logsdir(config=self._config)
        if logger_logsdir:
            ldir = _make_logsdir_dir(logger_logsdir)
        else:
>           ldir = _make_logsdir_tmpdir(self._config._tmpdirhandler)
E           AttributeError: 'Config' object has no attribute '_tmpdirhandler'

../py38/lib/python3.8/site-packages/pytest_logger/plugin.py:81: AttributeError

As for your problem, could you please create a minimal reproduction project? It's really hard to tell what is wrong without at least a full list of installed/used plugins :)

@aurzenligl
Copy link
Owner

aurzenligl commented Feb 11, 2024

Closing due to inactivity and infra changes, and python/pytest upgrades in the meantime

@aurzenligl aurzenligl closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2024
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

3 participants