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 there 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 line and let setuptools and nosetests do the rest: $ python setup.py nosetests You can try it yourself with the following lines. But first make sure that you have "Python2.7-dev" and "libssh-2-1-dev" installed on your system. Both are not Python requirements, so MONK can't handle them itself. 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 commit $ git checkout <this commit> # create a virtual conf to not play around with your system configuration $ virtualenv . $ source bin/activate # now let the tools do their jobs (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>
- Loading branch information