Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a convention to distinguish Python integration tests from unit tests?

The most common way of structuring a Python package with unit tests is as follows:

package/     __init__.py     module_1.py     module_2.py     module_n.py     test/         __init__.py         test_module_1.py         test_module_2.py         test_module_n.py 

I would like to distinguish between unit tests (of methods and functions) and integration tests (using the whole package and possibly involving other resources). Perhaps these tests should be in different packages, have different filenames, and/or include certain docstring comments.

Is there a standard convention for doing this?

like image 272
Jace Browning Avatar asked Mar 26 '13 14:03

Jace Browning


People also ask

Do you know what a unit test is and an integration test what is the difference and a system test?

Unit testing means testing individual modules of an application in isolation (without any interaction with dependencies) to confirm that the code is doing things right. Integration testing means checking if different modules are working fine when combined together as a group.

Is there unit testing in Python?

unittest has been built into the Python standard library since version 2.1. You'll probably see it in commercial Python applications and open-source projects. unittest contains both a testing framework and a test runner. unittest has some important requirements for writing and executing tests.


1 Answers

In our project we have unit tests inside each package, same as your case, and integration tests ,system tests, as a separate package on top level, i.e:

package_1/   __init__.py   module_1.py   module_n.py   test/     __init__.py     test_module_1.py     test_module_n.py package_n/   __init__.py   module_1.py   module_n.py   test/     __init__.py     test_module_1.py     test_module_n.py systemtest/   __init__.py   systemtest_1.py   systemtest_n.py 

I would use this convention even if you've got only one package in project. However I am not sure if this is a standard convention, or not.

like image 129
running.t Avatar answered Sep 17 '22 00:09

running.t