This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: import cleanup & nosetests intro
While investigating how to deliver a clear user/developer interface for MONK's unittest suite, I found that `nosetests` is a rather powerful tool for testing. As far as I understand it is a framework/tooling around Python's unittest library adding more features. Those features include: - automatic test discovery, no more need for test suites (but still possible) - simpler test methods without TestCase overhead and without removing any feature - decorators for Exception testing -> simpler code - plugins for coverage - plugins for various xml output That's why nosetests seems to be the standard tool for unit testing in the Python community. Making the decision to use nosetests and the need to change the unittests to comply with the new virtualenv-install-import policy makes a rewrite of the existing unit tests rather attractive. This commit starts that approach, deleting all the old school unit tests (which can be retrieved later on if necessary anyway). The first test will be about serial_conn, because that is the next development focus for MONK. It imports monk_tf and creates a SerialConn object in a very code-effective nosetest. Then setup.cfg and setup.py were adapted. Now it is possible to simply call the following commands and let setuptools and nosetests do the rest: $ pip install -r test-env.txt $ python setup.py nosetests If there are errors running the installations you might miss the required packages: #Ubuntu $ sudo apt-get install python-dev libssh2-1-dev # or Fedora $ yum install python-devel libssh2-devel # Sorry, no idea on Suse and the others Here's the example for you to follow: # checkout a fresh MONK $ mkdir fresh $ cd fresh $ git clone git@github.com:DFE/MONK $ cd MONK # checkout this branch $ git checkout f-unittest-virtualenv # create a virtual conf to not play around with your system configuration $ virtualenv . $ source bin/activate # now let the tools do their jobs (MONK)$ pip install -r test-env.txt (MONK)$ python setup.py nosetests <installing requirements> <installing monk_tf> check if creating a SerialConn object works.. ok <coverage statistics> <test results> OK With using `$ python setup.py develop` it's also possible to change your code and test suite while also being able to unit test it with `$ python setup.py nosetests` on the fly. Google for `setuptools develop` or ask me, if you want to know more about that. Last but not least this commit changes the place of the monk_tf folder again. The reason is, that all the tools' default behaviour is to expect the structure without the src/ folder. Before we decided that the src/ folder would be a better choice, because then potential additional packages might be structured in a more readable fashion with monk_tf. Because different tools are interacting now and each has the same default expectation it seems more logical to follow that expectation in the future. That's why this commit changes the structure instead of configuring all the tools to our structure. See Github Issue #34. Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com> Acked-by: Eik Binschek <binschek@dresearch-fe.de> Acked-by: Johannes Kroop <kroop@dresearch-fe.de>
- Loading branch information