[Networkit] Unittests in Python
meyerhenke at kit.edu
Thu Sep 18 14:55:47 CEST 2014
Thank you, Max, for the new feature. Christian's suggestions make sense
Let me add a general remark concerning the "separation" of Python + C++
Both parts, C++ and Python, are equally important and should be treated
as such in terms of documentation and interfaces. In particular, if
people develop C++ code, they must be able to use NetworKit as a C++
library with the same convenience as with our Python code (only to the
extent C++ offers, of course).
The assumption that most users use a certain part is a self-fulfilling
prophecy we should avoid. Both worlds are out there, important and
should be supported.
Am 18.09.14 um 11:47 schrieb Christian Staudt:
> 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?
> Am 18.09.2014 um 11:17 schrieb Maximilian Vogel
> <maximilian.vogel at student.kit.edu
> <mailto: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
>> The test code itself is based on the standard unittest 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 testand 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,
>>  https://docs.python.org/3.4/library/unittest.html
Karlsruhe Institute of Technology (KIT)
Institute of Theoretical Informatics (ITI)
Juniorprof. Dr. Henning Meyerhenke
Theoret. Informatics / Parallel Computing
KIT - University of the State of Baden-Wuerttemberg and
National Research Center of the Helmholtz Association
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5316 bytes
Desc: S/MIME Cryptographic Signature
More information about the NetworKit