In my Python project, I have a set of unittests, that load some data from files in a data sub-directory.
In PyCharm (Community 2019.3), running each of them individually all of them work, but they fail when running them in group, through doing right-click in the 'tests' directory of the Project sidebar structure.
Dir structure (showing just 1 example):
I load some mock files, as some .ini's: when executed individually, they work, when done in group, they fail. Output:
--- Logging error ---
Traceback (most recent call last):
Failure
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/suite.py", line 163, in _handleClassSetUp
setUpClass()
File "/home/.../tests/test_ConnectorUtils.py", line 22, in setUpClass
with open("data/settings.ini") as fsettings:
FileNotFoundError: [Errno 2] No such file or directory: 'data/settings.ini'
When run individually:
Testing started at 16:07 ...
/usr/bin/python3.6
/snap/pycharm-community/175/plugins/python-ce/helpers/pycharm/_jb_unittest_runner.py
--path /home/.../tests/test_ConnectorUtils.py
Launching unittests with arguments python -m
unittest /home/.../tests/test_ConnectorUtils.py in /home/.../tests
Ran 5 tests in 0.009s
OK
Not sure if it may be relevant, but before my files were not starting by test_, so, Pycharm was not detecting any tests, so, I renamed them, as it suggests in: Pycharm - no tests were found?
Config check I did:
Following: PyCharm unittests only work individually
Following: Pycharm and unittest does not work
I cannot find any issue, do someone has any idea, please?