pytest-dev / nose2pytest

Scripts to convert Python Nose tests to PyTest
Other
38 stars 12 forks source link

Add support for runpy invocation. #31

Closed jaraco closed 6 months ago

jaraco commented 6 months ago

Closes #26

jaraco commented 6 months ago

Here's how it works:

 nose2pytest feature/runpy @ tox -e py311 --notest -q
  py311: OK (4.07 seconds)
  congratulations :) (4.10 seconds)
 nose2pytest feature/runpy @ .tox/py311/bin/python -m nose2pytest --help
usage: __main__.py [-h] [-w] [-v] [--version] dir_name

Convert nose assertions to regular assertions for use by pytest

positional arguments:
  dir_name    folder name from which to start; all .py files under it will be converted

options:
  -h, --help  show this help message and exit
  -w          disable overwriting of original files
  -v          verbose output (list files changed, etc)
  --version   show program's version number and exit
jaraco commented 6 months ago

I notice now that by looking at it, nose2pytest does provide a runpy hook at nose2pytest.script, but that's unintuitive and non-standard and difficult to discover without inspecting the source. Better would be to be able to be executed from the root name.