Python:在setuptools的setup.py中进行集成

Ada*_*tan 5 python bdd setuptools python-behave

我编写了一个小实用程序包来处理文件权限.该结构遵循Python包标准:

.
|-- __init__.py                     # All the code is here, for now
`-- tests
    |-- __init__.py
    |-- permission_mode.feature     # Feature files for behave
    |-- steps                       
    |   |-- __init__.py
    |   `-- steps.py                # Step files for behave
    `-- test_modtools.py            # Nose tests
Run Code Online (Sandbox Code Playgroud)

鼻子和行为都可以从命令行运行测试而不会出现问题:

鼻子:

$ nosetests
.
----------------------------------------------------------------------
Ran 1 test in 0.002s

OK
Run Code Online (Sandbox Code Playgroud)

表现:

$ behave
Feature: Lots of cheese # permission_mode.feature:1

  Scenario: blah  # permission_mode.feature:2
    Given a       # steps/steps.py:1 0.000s
    Then b        # steps/steps.py:5 0.000s

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
2 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.000s
Run Code Online (Sandbox Code Playgroud)

我的setup.py文件包含以下测试规范:

test_suite='nose.collector',
tests_require=['nose']
Run Code Online (Sandbox Code Playgroud)

因此,python setup.py test运行鼻子测试与输出相同nosetests.

如何将行为配置为包的测试工具,以便python setup.py test运行?