Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pytest4 #116

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Enable pytest4 #116

wants to merge 6 commits into from

Conversation

wolever
Copy link
Owner

@wolever wolever commented Jan 9, 2021

No description provided.

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

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

@bnavigator bnavigator Apr 14, 2022

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

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
Copy link

kloczek commented Jul 12, 2022

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
Copy link

kloczek commented Jul 12, 2022

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.

@kloczek
Copy link

kloczek commented Jul 12, 2022

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

@kloczek
Copy link

kloczek commented Jul 12, 2022

See the full Fedora's patch

OK. Is it possible to update this PR?

@hroncok
Copy link

hroncok commented Jul 12, 2022

Possible? Probably yes

@kloczek
Copy link

kloczek commented Jul 12, 2022

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
Copy link

hroncok commented Jul 12, 2022

Or submit another one.

@sandrotosi
Copy link

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

@musicinmybrain
Copy link
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