Pregunta

I have written a small utility package for handling file permissions. The structure follows the Python package standards:

.
|-- __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

Both nose and behave run the tests from the command line without issues:

Nose:

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

OK

Behave:

$ 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

My setup.py file contains the following test spec:

test_suite='nose.collector',
tests_require=['nose']

And therefore python setup.py test runs nose tests with the same output as nosetests.

How do I configure behave as the package's test tool, so that python setup.py test will run behave?

¿Fue útil?

Solución

Look at "setup.py" from behave. It contains the usage of the colocated "setuptools_behave.py" test runner (and installs it).

RECIPE FOR USAGE:

# -- file:setup.py
from setuptools_behave import behave_test
...

setup(
    ...
    tests_require=["behave>=1.2.4"],
    cmdclass = {
        "behave_test": behave_test,
    },
    ...    
)

To verify it, execute "python setup.py --help-commands". It should contain a command "behave_test". Otherwise, run "python setup.py behave_test --help".

Otros consejos

Look this commit Provide simple test runner to run behave tests from setup.py.

Maybe for next release?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top