I'm using Visual Studio Code 1.39.2 and PyTest 6 with Python 3.8. I have this pytest.ini file
[pytest]
addopts = --docker-compose=./tests/docker-compose.yml --docker-compose-remove-volumes
env_override_existing_values = 1
env_files =
tests/.test_env
and below I have this at the top of my conftest.py file ...
def pytest_configure(config):
use_docker = False
try:
use_docker = config.getoption("--docker-compose-remove-volumes")
except:
pass
plugin_name = 'wait_for_docker' if use_docker else 'wait_for_server'
logging.info("\n\n\ndocker value %s", use_docker)
logging.info("\n\n\n\n\nplugin name %s", plugin_name)
if not config.pluginmanager.has_plugin(plugin_name):
config.pluginmanager.import_plugin("tests.plugins.{}".format(plugin_name))
However, in Visual Studio Code only, when I attempt to run a test, by clicking on the "Run Test" or "Debug Test" link in the editor ...
The test dies on the last line of the above ...
config.pluginmanager.import_plugin("tests.plugins.{}".format(plugin_name))
with the below error ....
INTERNALERROR> ValueError: Plugin already registered: tests.plugins.wait_for_docker=<module 'tests.plugins.wait_for_docker' from '/Users/davea/Documents/workspace/my_project/tests/plugins/wait_for_docker.py'>
This does not happen if I run the test by itself at a command line ...
pytest tests/functions/test_my_stuff.py
Does VS Code load plugins differently or is there some cached data I need to clear out to get things to work like the command line?