简体   繁体   中英

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 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 export TEST_CONF_NAME="../test.conf" ; python setup.py nosetests 2>&1 | cat -n | head -80 | tail -31 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.

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%] 

looks like a duplicate of :

How to run unit tests with "pip install"? which I answered some time ago.

however - setup.py test is deprecated, so i would not use it for a new development.

look at : https://setuptools.readthedocs.io/en/latest/setuptools.html#test-build-package-and-run-a-unittest-suite

therefore, for new projects I would suggest the use of a makefile.

make install
make test
make clean 
# etc ... 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM