Skip to content

Enable pytest4#116

Open
wolever wants to merge 6 commits into
masterfrom
pytest4
Open

Enable pytest4#116
wolever wants to merge 6 commits into
masterfrom
pytest4

Conversation

@wolever

@wolever wolever commented Jan 9, 2021

Copy link
Copy Markdown
Owner

No description provided.

PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2

PYTEST4 = pytest and pytest.__version__ >= '4.0.0'

@bnavigator bnavigator Apr 14, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do the same as the PY2 and PY3 constants above. It also evaluates to True if the runner is nose or unittest but when pytest is importable.

Workaround: add detect_runner() == 'pytest' to any conditional using it.

PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2

PYTEST4 = pytest and pytest.__version__ >= '4.0.0'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also note that e.g. '10.0.0' is lower than '4.0.0'. Something like this should work:

Suggested change
PYTEST4 = pytest and pytest.__version__ >= '4.0.0'
PYTEST4 = pytest and int(pytest.__version__.split('.')[0]) >= 4

@kloczek

kloczek commented Jul 12, 2022

Copy link
Copy Markdown

I've been tryimg to test this PR and pytest was not able to find units

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/parameterized-0.8.1
collected 0 items

========================================================================== no tests ran in 0.01s ===========================================================================

@kloczek

kloczek commented Jul 12, 2022

Copy link
Copy Markdown

After add --pyargs parameterized.test pytest was able to start however it failed on nose not found.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --pyargs parameterized.test
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/parameterized-0.8.1
collected 0 items / 1 error

================================================================================== ERRORS ==================================================================================
______________________________________________________________________ ERROR collecting test session _______________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib/python3.8/site-packages/parameterized/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
../../BUILDROOT/python-parameterized-0.8.1-3.fc35.x86_64/usr/lib/python3.8/site-packages/parameterized/test.py:6: in <module>
    from nose.tools import assert_equal, assert_raises
E   ModuleNotFoundError: No module named 'nose'
========================================================================= short test summary info ==========================================================================
ERROR
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.10s =============================================================================

Test suite shoud be rewrited to use pytest as nose is no longer maintained and it is only for python 2.x which is already EOSed.

@hroncok

hroncok commented Jul 12, 2022

Copy link
Copy Markdown

@kloczek

kloczek commented Jul 12, 2022

Copy link
Copy Markdown

On migration to pytest usefull could be https://github.com/schollii/nose2pytest/

@kloczek

kloczek commented Jul 12, 2022

Copy link
Copy Markdown

See the full Fedora's patch

OK. Is it possible to update this PR?

@hroncok

hroncok commented Jul 12, 2022

Copy link
Copy Markdown

Possible? Probably yes

@kloczek

kloczek commented Jul 12, 2022

Copy link
Copy Markdown

wolever

OK so my understandimg is that to update this PR it needas to be submittdd PR against forked repo and if @wolever will accept that PR thos PR will be updated as well.
Am I rigt?

@hroncok

hroncok commented Jul 12, 2022

Copy link
Copy Markdown

Or submit another one.

@sandrotosi

Copy link
Copy Markdown

thanks @hroncok ! i've applied the Fedora's patch to the debian package and now tests are passing with pytest 7

@musicinmybrain

Copy link
Copy Markdown
Contributor

I tried to rebase this on v0.9.0 so I could update the Fedora Linux package, but I found it wasn’t quite trivial. I’ll probably spend a little more time on it later, but I’ll also keep watching this PR for any further “official” work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants