quiqua / pytest-dotenv

A py.test plugin that parses environment files before running tests
MIT License
183 stars 18 forks source link

How to use pytest-dotenv only on integration test? #26

Open gsemet opened 1 year ago

gsemet commented 1 year ago

Hello

pytest-dotenv is very interesting for loading dotenv for integration tests (ie test that depends on the environment), for example to simulate the test environments in CI.

But this approach shall not be used for unit test that shall mock/stub/patch every dependency to outside, and typically the environment variable shall be simulated by something like monkeypatch.setenv. This is the I in FIRST principles (https://medium.com/@tasdikrahman/f-i-r-s-t-principles-of-testing-1a497acda8d6)

How we can restrict pytest-dotenv to only tests marked as "integration_tests"?