di / pytest-reqs

py.test plugin for checking requirements files
https://pypi.org/p/pytest-reqs
MIT License
25 stars 6 forks source link

Errors when running with a clean set of requirements #14

Closed maxnordlund closed 6 years ago

maxnordlund commented 6 years ago

Strangely enough, if you get errors it's fine, but if it's not then this happens:

$ pytest --reqs -m reqs
================================================= test session starts ==================================================
platform darwin -- Python 3.6.3, pytest-3.4.2, py-1.5.2, pluggy-0.6.0 -- /Users/maxno/.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/bin/python
cachedir: .pytest_cache
Using --randomly-seed=1520592236
Django settings: referanza.settings.local_settings (from ini file)
rootdir: /Users/maxno/Code/referanza, inifile: pytest.ini
plugins: xdist-1.20.0, timeout-1.2.0, testmon-0.9.6, splinter-1.8.5, reqs-0.0.7, regtest-0.15.1, randomly-1.2.1, notifier-1.0.1, mock-1.6.2, instafail-0.3.0, gitignore-1.3, freezegun-0.2.0, forked-0.2, factoryboy-1.3.1, django-3.1.2, datadir-ng-1.1.0, cov-2.5.1, bpdb-0.1.4, bdd-2.18.2, pylama-7.4.3, hypothesis-3.11.1, celery-4.1.0
collected 116 items

requirements.txt FAILED                                                                                          [ 50%]
requirements-dev.txt FAILED                                                                                      [100%]

======================================================= FAILURES =======================================================
__________________________________________________ requirements-check __________________________________________________
../../.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/pluggy/__init__.py:617: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../../.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/pluggy/__init__.py:222: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/pluggy/__init__.py:216: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
../../.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/pytest_regtest.py:199: in pytest_runtest_call
    regtest = item.funcargs.get("regtest")
E   AttributeError: 'ReqsItem' object has no attribute 'funcargs'
__________________________________________________ requirements-check __________________________________________________
Distribution "pytest" requires pytest==3.4.0 (from -r requirements-dev.txt (line 57)) but 3.4.2 is installed
================================================= 116 tests deselected =================================================
======================================= 2 failed, 116 deselected in 9.32 seconds =======================================
Exception ignored in: <generator object LoggingPlugin.pytest_runtest_call at 0x11376ef10>
Traceback (most recent call last):
  File "/Users/maxno/.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/_pytest/logging.py", line 399, in pytest_runtest_call
    yield
  File "/Users/maxno/.pyenv/versions/3.6.3/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/maxno/.pyenv/versions/venvs/4af8e580-f473-11e7-b2a7-9b1992f86568/lib/python3.6/site-packages/_pytest/logging.py", line 382, in _runtest_for
    del item.catch_log_handler
AttributeError: catch_log_handler
maxnordlund commented 6 years ago

It seems like pytest-regtest is the one trying to access funcargs, but it's this package that doesn't provide that method/property. Not sure if it makes sense, but I do think it's better to provide a dummy value then nothing.

maxnordlund commented 6 years ago

OK, so I've update regtest and everything is good now. I guess the issue with missing fucargs is still there, but I'll close this nevertheless.

di commented 6 years ago

Thanks for the report @maxnordlund. Seems to me that pytest-regtest should not expect the funcargs attribute to always exist.

Looking at a few other plugins, it doesn't seem like they provide a dummy funcargs attribute either, so pytest-regtest would probably also fail when combined with https://pypi.org/project/pytest-pep8/ for example.

I'm happy to provide the dummy attribute if it helps you use this plugin, though, so let me know if you have any issues getting this fixed in pytest-regtest.

maxnordlund commented 6 years ago

No problem, always happy to help 😃

It's fixed in a later version (don't know which as I upgraded quite a few), but I guess it comes down to try to being nice or acknowledge that there will be bad plugin and try to fixed them instead.

If a funcargs attribute should be added I think a warning would be good to add as well.