简体   繁体   English

如何通过 python-active-directory 模块中的 setup.py 运行单个鼻子测试?

[英]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 .我顽固地尝试将 Python 模块https://github.com/theatlantic/python-active-directory转换为 Python 3。你可以在这里看到我的努力https://github.com/nbmorgan/python-active-directory/树/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 export TEST_CONF_NAME="test.conf" ; python setup.py test
  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 .我曾尝试使用 setup 或 nosetest 帮助中描述的几种形式的 run single test 变体,但我通常会遇到module not found错误或某些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.如果有人可以指向我的命令行,让我只运行: test_client.TestADClient.test_domains ,那就太棒了。

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 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. export TEST_CONF_NAME="../test.conf" ; python setup.py nosetests 2>&1 | cat -n | head -80 | tail -31这很俗气,但让我知道了信息。

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.我不是 Python 模块构建器,只是试图提供帮助的模块用户。

Is running using setup a requirement?是否需要使用setup运行? 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).但实际运行失败,因为测试使用 pytest 固定装置(测试的 conf 参数)。 So you need to run it using pytest.所以你需要使用 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"? 如何使用“pip install”运行单元测试? which I answered some time ago.我前段时间回答过。

however - setup.py test is deprecated, so i would not use it for a new development.但是 - setup.py test已被弃用,所以我不会将它用于新的开发。

look at : https://setuptools.readthedocs.io/en/latest/setuptools.html#test-build-package-and-run-a-unittest-suite看看: 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.因此,对于新项目,我建议使用 makefile。

make install
make test
make clean 
# etc ... 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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