This short tutorial is related to lesson one of UW's PCE Python 220 - Summer 2019.
If you're experiencing a error like ModuleNotFoundError: No module named ...
, then follow try one of the two options below.
Basically, you have to tell Python the folder path for where the tests will run using by setting the PYTHONPATH
environment variable.
You can do this while running your tests.
First, navigate to the assignment
folder.
Then, follow the instructions below based on the location of your test scripts.
If you place your tests in the tests
folder like this.
/assignment
├── /inventory_management
│ ├── __init__.py
│ ├── electricAppliancesClass.py
│ ├── furnitureClass.py
│ ├── inventoryClass.py
│ ├── main.py
│ └── market_prices.py
└── /tests
├── __init__.py
├── test_integration.py
└── test_unit.py
Then run:
PYTHONPATH=inventory_management/ python -m unittest tests.test_unit
If you place your root project folder (aka the 'assignment' folder) like this.
/assignment
├── /inventory_management
│ ├── __init__.py
│ ├── electricAppliancesClass.py
│ ├── furnitureClass.py
│ ├── inventoryClass.py
│ ├── main.py
│ └── market_prices.py
├── test_unit.py
└── test_integration.py
Then run:
PYTHONPATH=inventory_management/ python -m unittest test_unit