This is an advanced workshop supposed to illustrate how you can structure and create tests using advanced testing patterns.
For python testing, it's convention to have a folder test/ or tests/ at the root of the project, next to the source folder for the main package of the project (in this case torchtools). The package structure of the test folder then attempts to reproduce the package structure of the main package, with the leaf nodes (i.e. the modules) named as the respective modules in main package, but either *_test or test_*.
For example, the matching test module for torchtools/fractional_array.py is test/torchtools/fractional_array_test.py.
This mirroring pattern can and should be further pursued within the modules, e.g. bundling tests of the CustomModel class as TestCustomModel, and tests of e.g. the __init__() method of TestCustomModel with fitting method name prefixes test__init__*(), etc.
For a step-by-step guide for advanced testing patterns, see utils_test.py.
To install this package, use poetry and run:
poetry installTo run the tests, use poetry shell to activate the python environment and from there, run:
pytest test/