tox-docker
tox-docker copied to clipboard
tox -p raises AttributeError at the end of the run
Whenever I run tox -p all
for a project that uses tox-docker
to start Docker containers, I get the following exception backtrace at the end of the run. This doesn't interfere with the run; all of the test environments report success before this happens. However, it does cause tox
to exit with a non-zero status.
This seems to only affect tox -p
, not running environments individually or sequentially using tox
without arguments or tox -e
. It happens with both Python 3.9 and Python 3.10.
Traceback (most recent call last):
File "/home/eagle/dvl/venvs/safir/bin/tox", line 8, in <module>
sys.exit(cmdline())
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox/session/__init__.py", line 44, in cmdline
main(args)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox/session/__init__.py", line 69, in main
exit_code = session.runcommand()
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox/session/__init__.py", line 197, in runcommand
return self.subcommand_test()
File "/usr/lib/python3.9/contextlib.py", line 126, in __exit__
next(self.gen)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox/session/__init__.py", line 205, in cleanup
self.hook.tox_cleanup(session=self)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox_docker/__init__.py", line 370, in tox_cleanup
stop_containers(venv)
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox_docker/__init__.py", line 381, in stop_containers
for container_name, container in envconfig._docker_containers.items():
File "/home/eagle/dvl/venvs/safir/lib/python3.9/site-packages/tox/config/__init__.py", line 1042, in __getattribute__
rv = object.__getattribute__(self, name)
AttributeError: 'TestenvConfig' object has no attribute '_docker_containers'
Looks like this is using tox 3.x ... would you be willing to upgrade to tox4 (and tox-docker 4.0.0a2 -- install with --pre
) to see if the issue persists there?
Ah, thank you, I hadn't noticed tox4. I can confirm that it does fix this issue. (It has a couple of other issues, one of which I see was already reported as https://github.com/tox-dev/tox/issues/2373 and the other of which I'll report in a separate issue.)
I am having the same issue with tox-docker 3.1.0 and tox 3.28.0. PyCharm requires the use of tox < 4.0.0 due to import issues in the tox plugin.
tox-docker==4.0.0a2 works, but I had to add
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
to the environment configuration, because docker-credential-desktop
is installed in /usr/local/bin