Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pytest: Hard-coded path - testing

The problem with this is that when trying to test the application, the test will also use the same hard-coded path. Thus we cannot test with values that are different from what the corporation has. This might include the credentials of the production database.

Not good.

import app

def test_app_1():
    res = app.do_something()
    ...

def test_app_2():
    res = app.do_something()
    ...
pytest -s test_app.py
/corporate/fixed/path/data.json
./corporate/fixed/path/data.json
.
2 passed in 0.07s