TB2J
TB2J copied to clipboard
[ENH]: Test suite
Hello!
While making #37 I realised that there is no clear test suite for the TB2J.
If there is some, please correct me.
I propose the following strategy using pytest + hypothesis for the discussion:
- Folder "utest" in the root folder (or other name with "test" in it)
- Inside "utest" folder the files and folder repeat the structure of the "TB2J" folder from the root folder.
- Each file and folder in the "utest" starts from the "test_"
- Each file and folder in the "utest" contains unit tests for the corresponding functions and classes of the package.
- Each function in the "utest" starts with "test_" and
- Each class in "utest" starts with "Test"
- Each class and function in the "utest" has the name of the class or function from the package for which it is written (if applicable).
With this strategy the tests can be run with the command from the root folder (after pip install pytest hypothesis
):
pytest -s
Example:
root/
├── ...
├── TB2J/
│ ├── file1.py
│ │ ├──> def function_1():
│ │ └──> class MyClass:
│ ├── submodule/
│ │ └── file2.py
│ │ └──> def function_2():
│ └── ...
├── utest/
│ ├── test_file1.py
│ │ ├──> def test_function_1_behaviour():
│ │ ├──> def test_function_1_raises():
│ │ └──> class TestMyClass:
│ ├── test_submodule/
│ │ └── test_file2.py
│ │ └──> def test_function_2():
│ └── ...
└── ...
P.S. An example of this strategy can be looked at in one of my repositories.
Indeed there is no unit test suite right now. It is definitely good to have it. And it can eventually be integrated into the CI: https://github.com/mailhexu/TB2J/blob/master/.travis.yml I will start adding it. Best wishes, HeXu
Great!
It could be a good idea to add testing with the different Python versions to the CI to ensure that the code is compatible with the stated minimal and later versions of Python.
Best, Andrey