Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override pytest.ini when running tests from the command line?

Tags:

People also ask

Where do I put the pytest ini file?

Users can customize some pytest behavior using a configuration file called pytest. ini . This file is usually placed at the root of the repository and contains a number of configuration values that are applied to all test runs for that project.


I have a codebase containing multiple python packages. There is also a pytest.ini file that contains the names of these files.

example directory structure:

main_dir
  |
  |
  |--- package1
  |
  |--- package2
  |
  |--- pytest.ini

pytest.ini looks like this

[pytest.ini]
addopts = package1 package2

The issue is because of pytest.ini I am not able to run tests just package wise. For example py.test package1\ now runs tests for package2 tests as well.

If I remove pytest.ini file, the command works as expected. Only option I see is to maintain an uncommitted version of pytest.ini which I keep changing according to my needs.

How do I override the pytest.ini settings and run tests only package wise?