[Networkit] Unittests in Python

Christian Staudt christian.staudt at kit.edu
Thu Sep 18 11:47:12 CEST 2014


Thank you, Max. I’ve tested "python setup.py test“ and it works. It seems to be very convenient for testing. Visually, test results could be better separated from compiler output (and possibly colored?).

So now that we have a system for unit tests in Python in place, I propose the following policy on testing:
- Unit tests on the C++ layer are necessary for development, profiling and debugging of C++ code. However, we should try to distinguish between low-level and high-level tests. High-level functionality tests (e.g. „Does my algorithm work also with this specific network?“...) should be implemented in the Python layer. This ensures that these functionality tests also test the main interface of the package that most users will interact with. 
- Of course, all the functionality implemented on the Python layer must be tested in Python. 
- Individual unit tests should not run longer than a couple of seconds, since testing must be frequent and fast. 
- Needless to say, unit tests should not be misused for implementing workflows or experiments, this is what the Python interface is for. Implement your workflows and experiments in separate Python scripts. Sometimes such scripts are of general interest and can be added to the NetworKit scripts folder.

Any comments on that?

Best,
Christian


Am 18.09.2014 um 11:17 schrieb Maximilian Vogel <maximilian.vogel at student.kit.edu>:

> Hello NetworKit developers,
> 
> With changeset d6245be01453, I pushed a first draft for unittests in Python. Here's a brief explanation:
> 
> Python tests will go into the folder networkit/test. There is/will be a seperate folder for the extension, and each submodule of networkit that is a folder, e.g. gephi. Tests for file based modules like centrality.py will go under test_centrality.py. However, this is very flexible.
> The test code itself is based on the standard unittest[0] package.
> 
> Regarding the location where the test code is supposed to go: Christian raised the issue that it would be nice to have the test code directly in the modules, also as code examples for users.
> However the advantage of the current approach is that it works out-of-the-box with setuptools' own python setup.py test command, which will build the extension and then run the Python based unittests. This command is now modified to compile and run the C++ unittests of NetworKit before the Python based stuff happens.
> 
> Feel free to try python setup.py test and to post any suggestions (e.g. for console output (verbosity) or command line options to make the test command more flexible/convenient).
> 
> python setup.py nosetests would work aswell if nose is installed, but currently I don't see the benefits of nose.
> 
> Another issue I'd like to address: How to test the _NetworKit extension module? Although it would be very redundant, I suggest to copy and adapt the C++ unit tests to Python, to make sure that the parameters and results are passed through properly.
> 
> What is your opinion on the subject?
> 
> Best regards,
> Max
> 
> 
> [0] https://docs.python.org/3.4/library/unittest.html
> <ATT00001.c>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20140918/a316d79d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20140918/a316d79d/attachment.sig>


More information about the NetworKit mailing list