Closed ktthross closed 4 months ago
Hi,
pytest -c configs/conftest.py -c configs/pytest.ini
doesn't work, there can only be one config file, and a conftest file is not a config file in any case. So remove the -c configs/conftest.py
part.
Next, to have the conftest file loaded, move it to the test directory where it's needed, that is test_pytest/conftest.py
.
This issue is stale because it has been open for 14 days with no activity.
Stale for a long time and no-follow up, just helping the bot here a bit and closing manually.
pip list
from the virtual environment you are usingHello there. We want to disable certain directories from running and sometimes specific files. We have conftest.py to disable specific files and a pytest.ini to disable directories from being tested. We cannot disable the tests themselves because pytest will import the test modules and in certain environments on our team, the imports are not available so the test will fail. We invoke pytest and pass the -c argument for both files along with the --rootdir argument. When pytest.ini and conftest.py are in the root directory everything works as expected. When they are in the subdirectory pytest fails to use the config files.
This command works
This command does not work
Here is a gitrepo that contains the files for this example https://github.com/ktthross/test_pytest
Pip list
Package Version Editable project location
awscli 1.27.125 blinker 1.6.2 boltons 23.0.0 boto3 1.26.107 botocore 1.29.125 brotlipy 0.7.0 certifi 2022.12.7 cffi 1.15.1 charset-normalizer 2.0.4 click 8.1.3 colorama 0.4.4 conda 23.3.1 conda-content-trust 0.1.3 conda-package-handling 2.0.2 conda_package_streaming 0.7.0 contourpy 1.0.7 cryptography 39.0.1 cycler 0.11.0 Cython 0.29.34 docutils 0.16 exceptiongroup 1.1.1 flake8 6.0.0 Flask 2.3.2 Flora 0.0.0 /home/kthrossell/working/flora fonttools 4.39.4 gitdb 4.0.10 GitPython 3.1.31 grpcio 1.56.2 grpcio-tools 1.56.2 idna 3.4 iniconfig 2.0.0 itsdangerous 2.1.2 Jinja2 3.1.2 jmespath 1.0.1 jsonpatch 1.32 jsonpointer 2.1 kiwisolver 1.4.4 MarkupSafe 2.1.3 matplotlib 3.7.1 mccabe 0.7.0 numpy 1.24.2 packaging 23.0 Pillow 9.5.0 pip 23.3.1 pluggy 1.0.0 project-euler 1.2.59 protobuf 4.23.4 pyasn1 0.5.0 pycodestyle 2.10.0 pycosat 0.6.4 pycparser 2.21 pyflakes 3.0.1 pyOpenSSL 23.0.0 pyparsing 3.0.9 PySocks 1.7.1 pytest 7.3.1 python-dateutil 2.8.2 PyYAML 5.4.1 requests 2.28.1 rsa 4.7.2 ruamel.yaml 0.17.21 ruamel.yaml.clib 0.2.6 s3transfer 0.6.0 satellite 0.3.6 /home/kthrossell/working/satellite SCons 4.5.2 setuptools 65.6.3 six 1.16.0 smmap 5.0.0 test-pytest 0.1.0 /home/kthrossell/working/test_pytest tomli 2.0.1 toolz 0.12.0 tqdm 4.65.0 urllib3 1.26.15 Werkzeug 2.3.6 wheel 0.37.1 zstandard 0.19.0
pytest verions and OS
pytest -V pytest 7.3.1
This has also been tested on 7.4.0
Distributor ID: Ubuntu Description: Ubuntu 20.04.6 LTS Release: 20.04 Codename: focal