Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a single nosetest via setup.py in the python-active-directory module?

I am stubbornly trying to convert the Python module https://github.com/theatlantic/python-active-directory to Python 3. You can see my efforts here https://github.com/nbmorgan/python-active-directory/tree/master3.

I have figured out the following things, I can run the test suite within the cloned project by either:

  1. export TEST_CONF_NAME="test.conf" ; python setup.py test or
  2. export TEST_CONF_NAME="../test.conf" ; python setup.py nosetests

This creates a huge output with the first simple test at the top. I have tried to use several forms of the run single test variations described in the help for setup or nosetest, but I'm usually met with module not found errors or some variant of test not defined.

If someone could point me at the command line that would let me run just: test_client.TestADClient.test_domains that would be awesome.

For now I am using: export TEST_CONF_NAME="../test.conf" ; python setup.py nosetests 2>&1 | cat -n | head -80 | tail -31 which is cheesy, but gets me the information.

I would like to thank the author for having tests - which makes a cold approach to a refactor possible. I am not a Python module builder, just a module user trying to help.

like image 884
Frobbit Avatar asked Feb 09 '19 02:02

Frobbit


1 Answers

Is running using setup a requirement? I run certain test like this:

nosetests tests/core/test_client.py:TestADClient.test_search --collect
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK

But actual run fails because tests use pytest fixture (conf argument for tests). So you need to run it using pytest.

$ pytest tests/core/test_client.py::TestADClient::test_search -vv
============================ test session starts ============
...
collected 1 item                                                             
tests/core/test_client.py::TestADClient::test_search SKIPPED                           [100%] 
like image 101
nmb.ten Avatar answered Oct 26 '22 14:10

nmb.ten