mailhexu / TB2J

a python package for computing magnetic interaction parameters
BSD 2-Clause "Simplified" License
67 stars 29 forks source link

[ENH]: Test suite #38

Open adrybakov opened 11 months ago

adrybakov commented 11 months ago

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:

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.

mailhexu commented 11 months ago

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

adrybakov commented 11 months ago

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