I’m not sure why py.test does not add the current directory in the PYTHONPATH itself, but here’s a workaround (to be executed from the root of your repository):
python -m pytest tests/
It works because Python adds the current directory in the PYTHONPATH for you.
More Related Contents:
- How to properly assert that an exception gets raised in pytest?
- How to test a function with input call?
- Pytest fixture for a class through self not as method argument
- how to share a variable across modules for all tests in py.test
- How to mock a readonly property with mock?
- python mocking raw input in unittests
- In pytest, what is the use of conftest.py files?
- Using pytest with a src layer
- TransactionManagementError “You can’t execute queries until the end of the ‘atomic’ block” while using signals, but only during Unit Testing
- Monkey patching a class in another module in Python
- How do I configure PyCharm to run py.test tests?
- Mocking a module import in pytest
- How can one mock/stub python module like urllib
- How to run Django’s test database only in memory?
- How to test Python 3.4 asyncio code?
- Writing unit tests in Python: How do I start? [closed]
- Python library ‘unittest’: Generate multiple tests programmatically [duplicate]
- How can I mock user input (from “input” in 3.x, or “raw_input” in 2.x) for a unit test?
- how to test if a variable is pd.NaT?
- How to monkeypatch python’s datetime.datetime.now with py.test?
- pytest cannot find module [duplicate]
- How to test or mock “if __name__ == ‘__main__'” contents
- How to run django unit-tests on production database?
- py.test skips test class if constructor is defined
- VSCode pytest test discovery fails
- Running a specific test case in Django when your app has a tests directory
- Unit testing a python app that uses the requests library
- In which order are pytest fixtures executed?
- Python Unit Testing: Automatically Running the Debugger when a test fails
- How can I specify a database for Django Tests to use instead of having it build it every time?