Python: integrate into setup.py

I wrote a small package for processing 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 noses and behavior run tests from the command line without any problems:

Nose:

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

OK

Lead:

$ 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 file setup.pycontains the following test specification:

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

And so it python setup.py testruns nasal tests with the same output as nosetests.

How to configure behavior as a package testing tool, so that python setup.py testwill work?

+4
source share
2 answers

"setup.py", . "setuptools_behave.py" ( ).

:

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

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

, "python setup.py --help-commands". "behave_test". "python setup.py behave_test --help".

+3
+1

Source: https://habr.com/ru/post/1526313/


All Articles