You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So while playing around with molecule, I tried running my first Testinfra specs. All good, but things would fail before even running my test. Sample output:
============================= test session starts ==============================
platform darwin -- Python 3.6.5, pytest-4.1.1, py-1.7.0, pluggy-0.8.1
rootdir: /Users/myusernamehere/Projects/personal/consul-appliance/molecule/default, inifile:
plugins: testinfra-1.16.0
collected 2 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/_pytest/main.py", line 203, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/_pytest/main.py", line 242, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/hooks.py", line 284, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/_pytest/main.py", line 252, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/_pytest/main.py", line 471, in perform_collect
INTERNALERROR> hook.pytest_collection_finish(session=self)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/hooks.py", line 284, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/manager.py", line 68, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/manager.py", line 62, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/myusernamehere/Projects/personal/consul-appliance/venv/lib/python3.6/site-packages/testinfra/plugin.py", line 183, in pytest_collection_finish
INTERNALERROR> session.config.warn('C1', msg)
INTERNALERROR> AttributeError: 'Config' object has no attribute 'warn'
========================= no tests ran in 0.66 seconds =========================
I dug into the source code and found that the pytest hook function pytest_collection_finish (line 160 of plugin.py in the version of Testinfra I'm using), was failing to call session.config.warn.
From this point, I've come to realize I can avoid this call entirely by using the non-deprecated syntax of host.XXX instead of passing XXX as a parameter (in my case, XXX was the User module). This means my tests are now able to run cause I avoid that conditional branch of the if tree entirely.
From my digging before realizing this problem, I started looking through the pytest_hookspec, which lead me to this section of the pytest source code, where I noticed an oddly relevant commit message that was linked to this relevant discussion. Based off that discussion, it seems like there was a plan to deprecate and fully remove the .warn function from the Config object. I couldn't understand what changes consumers needed to make as I'm a bit of a scrub when it comes to Python 😄 , but it looks like version 4.0.X of pytest will require calls to the .warn function to be replaced with some new usage of a warning system. I'd offer a code change, but I honestly am very new to Python, let alone what looks to be advanced Python programing.
I don't have any pressing need for a fix on this, but wanted to open this issue in case a hard reason for adding pytest 4.0 support was needed.
The text was updated successfully, but these errors were encountered:
So while playing around with molecule, I tried running my first Testinfra specs. All good, but things would fail before even running my test. Sample output:
I dug into the source code and found that the pytest hook function
pytest_collection_finish
(line 160 ofplugin.py
in the version of Testinfra I'm using), was failing to callsession.config.warn
.From this point, I've come to realize I can avoid this call entirely by using the non-deprecated syntax of
host.XXX
instead of passingXXX
as a parameter (in my case,XXX
was theUser
module). This means my tests are now able to run cause I avoid that conditional branch of theif
tree entirely.From my digging before realizing this problem, I started looking through the pytest_hookspec, which lead me to this section of the pytest source code, where I noticed an oddly relevant commit message that was linked to this relevant discussion. Based off that discussion, it seems like there was a plan to deprecate and fully remove the
.warn
function from theConfig
object. I couldn't understand what changes consumers needed to make as I'm a bit of a scrub when it comes to Python 😄 , but it looks like version 4.0.X of pytest will require calls to the.warn
function to be replaced with some new usage of a warning system. I'd offer a code change, but I honestly am very new to Python, let alone what looks to be advanced Python programing.I don't have any pressing need for a fix on this, but wanted to open this issue in case a hard reason for adding pytest 4.0 support was needed.
The text was updated successfully, but these errors were encountered: