Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Tests should run on an installed version #34

Closed
erikbgithub opened this issue Feb 26, 2013 · 3 comments
Closed

Tests should run on an installed version #34

erikbgithub opened this issue Feb 26, 2013 · 3 comments
Assignees

Comments

@erikbgithub
Copy link
Contributor

Problem

MONK's unittests currently run the sourcecode on system.path modifications, which is kind of hacky. Now that MONK can be installed in different ways, the unittests should also run such an install and simply import monk_tf withouth anything else.

Solution

  • deleting the system.path line
  • correcting the import to import monk_tf as monk
  • changing the test code accordingly

Notes

  • see branch f-unittests-virtualenv
@ghost ghost assigned sledz Mar 4, 2013
erikbgithub added a commit that referenced this issue May 13, 2013
See Github Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Github Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Github Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Github Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Github Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
erikbgithub added a commit that referenced this issue May 13, 2013
See Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
@ghost ghost assigned erikbgithub May 13, 2013
erikbgithub added a commit that referenced this issue May 13, 2013
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>
erikbgithub added a commit that referenced this issue May 13, 2013
Because the interface for testing and installing did once more got closer to
the standard, there is already a payoff in the travis-ci configuration, were
now less lines of code are needed.

In the new configuration the setuptools standard interface is used for
installation as well as testing. The only requirements necessary for
installation left are python2.7-dev and libssh2-1-dev, which are C-header
dependencies needed for pylibssh2 to build. As far as I see there is not much
we can do about those requirements for now.

See Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
@erikbgithub
Copy link
Contributor Author

The following commits contain the reviewable state

erikbgithub added a commit that referenced this issue May 21, 2013
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>
erikbgithub added a commit that referenced this issue May 21, 2013
Because the interface for testing and installing did once more got closer to
the standard, there is already a payoff in the travis-ci configuration, were
now less lines of code are needed.

In the new configuration the setuptools standard interface is used for
installation as well as testing. The only requirements necessary for
installation left are python2.7-dev and libssh2-1-dev, which are C-header
dependencies needed for pylibssh2 to build. As far as I see there is not much
we can do about those requirements for now.

See Issue #34.

Signed-off-by: Erik Bernoth <erik.bernoth@gmail.com>
@binschek
Copy link
Member

ACK

1 similar comment
@infeix
Copy link
Contributor

infeix commented May 21, 2013

ACK

erikbgithub added a commit that referenced this issue May 21, 2013
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>
erikbgithub added a commit that referenced this issue May 21, 2013
Because the interface for testing and installing did once more got closer to
the standard, there is already a payoff in the travis-ci configuration, were
now less lines of code are needed.

In the new configuration the setuptools standard interface is used for
installation as well as testing. The only requirements necessary for
installation left are python2.7-dev and libssh2-1-dev, which are C-header
dependencies needed for pylibssh2 to build. As far as I see there is not much
we can do about those requirements for now.

See 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>
erikbgithub added a commit that referenced this issue May 21, 2013
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>
erikbgithub added a commit that referenced this issue May 21, 2013
Because the interface for testing and installing did once more got closer to
the standard, there is already a payoff in the travis-ci configuration, were
now less lines of code are needed.

In the new configuration the setuptools standard interface is used for
installation as well as testing. The only requirements necessary for
installation left are python2.7-dev and libssh2-1-dev, which are C-header
dependencies needed for pylibssh2 to build. As far as I see there is not much
we can do about those requirements for now.

See 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>
erikbgithub added a commit that referenced this issue May 21, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants