Python tests are not working from command-line but from IntelliJ IDEA run configuration
I have the python project like below:
-- Folder1
--Sub folder1
-- test1.py
-- test2.py
-- Folder2
-- config.py
-- resources
--some.ini
Have couple of tests in both test1 and test2.py files, and running fine when I run separately or run by setting the custom additional argument as discover (to achieve *python -m unittest discover*) which runs all tests as expected. No issues.
When I try to run from command line like below which I expect to run all tests, and it's running but fails in config.py.
python -m unittest discover
Config.py
class Config:
@lru_cache
def get(self, which_section, which_prop) -> str:
config = configparser.RawConfigParser()
config.read("../../resources/properties.ini")
return config.get(which_section, which_prop)
Always getting NoSection error. I understand that the configparser lib error reporting is not exact, and learnt that if the file path is wrong I will get this error too. So not sure why the file path is not getting resolved when I run from command line.
So, not sure what I am missing which impacts this error here but running from run configuration. Something I am guessing related to the options to add content roots/source roots to PYTHON PATH but not sure. Appreciate any help.
Please sign in to leave a comment.