18

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.

karel
  • 5,489
  • 46
  • 45
  • 50
Frobbit
  • 1,652
  • 17
  • 30
  • Mythical Bonus Points (MBP) for showing how to launch a test with debugger + pycharm – Frobbit Feb 09 '19 at 02:55
  • 1
    Just FYI.. are you aware that they merged a PR adding Python 3 support only a week ago: https://github.com/theatlantic/python-active-directory/pull/1 – cody Mar 05 '19 at 23:06
  • I back burnered this. Thanks for the info. I still want to drive this question so that people that know enough to be dangerous but are not familiar with pytest / nose can run tests in modules. – Frobbit Mar 21 '19 at 23:19

2 Answers2

1

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%] 
nmb.ten
  • 2,158
  • 1
  • 20
  • 18
  • No requirement to run setup. It was the only path that did anything function for me. Where are you standing (pwd) in the tree when you run the pytest command? – Frobbit Mar 21 '19 at 22:56
  • In root folder of the repo - `ls -> ... setup.cfg setup.py tests ...` – nmb.ten Mar 22 '19 at 08:38
0

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 ... 
bitranox
  • 1,664
  • 13
  • 21