Skip to content

[Installation] PyTest Installation Failure #8836

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

Closed
Rubix982 opened this issue Jun 30, 2021 · 3 comments
Closed

[Installation] PyTest Installation Failure #8836

Rubix982 opened this issue Jun 30, 2021 · 3 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@Rubix982
Copy link

Rubix982 commented Jun 30, 2021

Detailed Description

PyTest will not install and is throwing an error when ran for tests, that is pytest.

Pip Freeze

attrs==21.2.0
iniconfig==1.1.1
packaging==20.9
pluggy==0.13.1
py==1.10.0
pyparsing==2.4.7
pytest==6.2.4
toml==0.10.2

PyTest And OS Versions

pytest is 6.2.4, and the OS is Linux saif-kubuntu 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux, with python 3.8.5.

Minimal working example

Running the code below will generate the error,

cd ~
mkdir pytest_bug_report && cd pytest_bug_report
virtualenv -m venv venv
source venv/bin/activate
pip install pytest
cat <<EOT >> test_sample.py
# content of test_sample.py
def inc(x):
    return x + 1

def test_answer():
    assert inc(3) == 5
EOT
pytest

Or even simply,

cd ~
mkdir pytest_bug_report && cd pytest_bug_report
virtualenv -m venv venv
source venv/bin/activate
pip install pytest
pytest --version # this also generates the error for some reason

The error thrown is,

Traceback (most recent call last):
  File "/home/saif/.local/bin/pytest", line 5, in <module>
    from pytest import main
  File "/home/saif/.local/lib/python3.8/site-packages/pytest.py", line 13, in <module>
    from _pytest.fixtures import fixture, yield_fixture
  File "/home/saif/.local/lib/python3.8/site-packages/_pytest/fixtures.py", line 839, in <module>
    class FixtureFunctionMarker(object):
  File "/home/saif/.local/lib/python3.8/site-packages/_pytest/fixtures.py", line 841, in FixtureFunctionMarker
    params = attr.ib(convert=attr.converters.optional(tuple))
TypeError: attrib() got an unexpected keyword argument 'convert'

Yes, I've looked at similar issues, such as,

The bottom line solution is to have the latest pytest, and attrs, I have both at 21.2.0, and at 6.2.4.

@The-Compiler
Copy link
Member

The-Compiler commented Jun 30, 2021

Your traceback says:

  File "/home/saif/.local/lib/python3.8/site-packages/_pytest/fixtures.py", line 841, in FixtureFunctionMarker
    params = attr.ib(convert=attr.converters.optional(tuple))

yet that doesn't correspond to the pytest 6.2.4 sources.

convert= was changed to converter= there in 82cdc48, released as part of pytest 3.5.0.

Judging from the traceback, what's running there is actually pytest 3.3.1 (from Dec 2017).

Can you show the full output of your reproducer above please?

@The-Compiler The-Compiler added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Jun 30, 2021
@Rubix982
Copy link
Author

Rubix982 commented Jun 30, 2021

I did not realize that. Thank for you pointing that out!

For some reason, even despite that, I had my virtualenv activated, when I ran pytest, it ran the pytest installed globally, which was a long time ago. I just did pip install -U pytest, and found that a 1.8.0 was residing globally. I updated it to the latest. And with that, it works now.

This was completely my fault, fixed it now. Thank for you the time, though.

Closing.

@The-Compiler
Copy link
Member

Great, no worries and thanks for the follow-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants