Skip to content

Fix support for pytest 4.1 #45

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

Merged
merged 2 commits into from
Jan 7, 2019
Merged

Conversation

nicoddemus
Copy link
Member

Also stop using the deprecated pytest.config global

Fix #44

@addyess
Copy link

addyess commented Jan 7, 2019

🎉

@altendky altendky merged commit 8f484cd into pytest-dev:master Jan 7, 2019
@nicoddemus nicoddemus deleted the pytest-4.1 branch January 7, 2019 20:57
@ktdreyer
Copy link

ktdreyer commented Jan 8, 2019

I'm testing with master, and I think this change breaks the @pytest.inlineCallbacks decorator on my tests.

E   AttributeError: 'module' object has no attribute 'inlineCallbacks'

@altendky
Copy link
Member

altendky commented Jan 8, 2019

I confirmed it's broken now. I'm not really a fan of putting this stuff into the pytest namespace, but sure, a change like that should come with warnings and deprecations and time... #41

altendky@lt:~$ rm -rf testvenv
altendky@lt:~$ python3 -m venv testvenv
altendky@lt:~$ testvenv/bin/pip install pytest==4.1.0 git+https://github.com/pytest-dev/pytest-twisted@8f484cdec2b55eefd4a16191ff54d724641f0beb
Collecting git+https://github.com/pytest-dev/pytest-twisted@8f484cdec2b55eefd4a16191ff54d724641f0beb
  Cloning https://github.com/pytest-dev/pytest-twisted (to revision 8f484cdec2b55eefd4a16191ff54d724641f0beb) to /tmp/pip-req-build-acfvdwfd
Collecting pytest==4.1.0
  Using cached https://files.pythonhosted.org/packages/95/6a/4122affe57eb3857874ef959a73f362e51b23812b96c92e073b16e1effd0/pytest-4.1.0-py2.py3-none-any.whl
Collecting greenlet (from pytest-twisted==1.8)
  Using cached https://files.pythonhosted.org/packages/9d/ef/ac10aa1293f64939e4511909c570d969566126214af5dd7ba0afd353d88b/greenlet-0.4.15-cp37-cp37m-manylinux1_x86_64.whl
Collecting decorator (from pytest-twisted==1.8)
  Using cached https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting six>=1.10.0 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting more-itertools>=4.0.0 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/a4/a6/42f17d065bda1fac255db13afc94c93dbfb64393eae37c749b4cb0752fc7/more_itertools-5.0.0-py3-none-any.whl
Collecting pluggy>=0.7 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/1c/e7/017c262070af41fe251401cb0d0e1b7c38f656da634cd0c15604f1f30864/pluggy-0.8.0-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl
Collecting py>=1.5.0 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/3e/c7/3da685ef117d42ac8d71af525208759742dd235f8094221fdaafcd3dba8f/py-1.7.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./testvenv/lib/python3.7/site-packages (from pytest==4.1.0) (39.0.1)
Collecting atomicwrites>=1.0 (from pytest==4.1.0)
  Using cached https://files.pythonhosted.org/packages/3a/9a/9d878f8d885706e2530402de6417141129a943802c084238914fa6798d97/atomicwrites-1.2.1-py2.py3-none-any.whl
Installing collected packages: six, more-itertools, pluggy, attrs, py, atomicwrites, pytest, greenlet, decorator, pytest-twisted
  Running setup.py install for pytest-twisted ... done
Successfully installed atomicwrites-1.2.1 attrs-18.2.0 decorator-4.3.0 greenlet-0.4.15 more-itertools-5.0.0 pluggy-0.8.0 py-1.7.0 pytest-4.1.0 pytest-twisted-1.8 six-1.12.0
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~$ testvenv/bin/python -c 'import pytest; print(pytest.inlineCallbacks)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'pytest' has no attribute 'inlineCallbacks'

But it is also broken before this PR and with pytest==4.0.2.

altendky@lt:~$ rm -rf testvenv
altendky@lt:~$ python3 -m venv testvenv
altendky@lt:~$ testvenv/bin/pip install pytest==4.0.2 git+https://github.com/pytest-dev/pytest-twisted@b78a6c99199aee7a2ee07c366eaba77bb080ff28
Collecting git+https://github.com/pytest-dev/pytest-twisted@b78a6c99199aee7a2ee07c366eaba77bb080ff28
  Cloning https://github.com/pytest-dev/pytest-twisted (to revision b78a6c99199aee7a2ee07c366eaba77bb080ff28) to /tmp/pip-req-build-7745iqph
Collecting pytest==4.0.2
  Using cached https://files.pythonhosted.org/packages/19/80/1ac71d332302a89e8637456062186bf397abc5a5b663c1919b73f4d68b1b/pytest-4.0.2-py2.py3-none-any.whl
Collecting greenlet (from pytest-twisted==1.8)
  Using cached https://files.pythonhosted.org/packages/9d/ef/ac10aa1293f64939e4511909c570d969566126214af5dd7ba0afd353d88b/greenlet-0.4.15-cp37-cp37m-manylinux1_x86_64.whl
Collecting decorator (from pytest-twisted==1.8)
  Using cached https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl
Collecting atomicwrites>=1.0 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/3a/9a/9d878f8d885706e2530402de6417141129a943802c084238914fa6798d97/atomicwrites-1.2.1-py2.py3-none-any.whl
Collecting pluggy>=0.7 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/1c/e7/017c262070af41fe251401cb0d0e1b7c38f656da634cd0c15604f1f30864/pluggy-0.8.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./testvenv/lib/python3.7/site-packages (from pytest==4.0.2) (39.0.1)
Collecting six>=1.10.0 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting more-itertools>=4.0.0 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/a4/a6/42f17d065bda1fac255db13afc94c93dbfb64393eae37c749b4cb0752fc7/more_itertools-5.0.0-py3-none-any.whl
Collecting py>=1.5.0 (from pytest==4.0.2)
  Using cached https://files.pythonhosted.org/packages/3e/c7/3da685ef117d42ac8d71af525208759742dd235f8094221fdaafcd3dba8f/py-1.7.0-py2.py3-none-any.whl
Installing collected packages: attrs, atomicwrites, pluggy, six, more-itertools, py, pytest, greenlet, decorator, pytest-twisted
  Running setup.py install for pytest-twisted ... done
Successfully installed atomicwrites-1.2.1 attrs-18.2.0 decorator-4.3.0 greenlet-0.4.15 more-itertools-5.0.0 pluggy-0.8.0 py-1.7.0 pytest-4.0.2 pytest-twisted-1.8 six-1.12.0
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~$ testvenv/bin/python -c 'import pytest; print(pytest.inlineCallbacks)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'pytest' has no attribute 'inlineCallbacks'
altendky@lt:~$ grep -B 1 '"inlineCallbacks"' testvenv/lib/python3.7/site-packages/pytest_twisted.py
def pytest_namespace():
    return {"inlineCallbacks": inlineCallbacks, "blockon": blockon}

For that matter, I haven't found a version pair yet where that test passes.

@ktdreyer, what's your pip freeze for the case where it worked? Might save me some time tracking this down.

(I did also try with twisted==18.9.0 installed)

@ktdreyer
Copy link

ktdreyer commented Jan 8, 2019

Unfortunately I just blew away my virtualenv where this reproduces :(

I can just switch my projects over to using @pytest_twisted.inlineCallbacks . I didn't realize this was preferred until I read #41

jeremycline added a commit to jeremycline/fedora-messaging that referenced this pull request Jan 8, 2019
Upstream is working on a fix[0], but until then this will let CI pass.

[0] pytest-dev/pytest-twisted#45

Signed-off-by: Jeremy Cline <[email protected]>
@nicoddemus
Copy link
Member Author

nicoddemus commented Jan 8, 2019

@altendky python -c 'import pytest; print(pytest.inlineCallbacks)' won't work because pytest_configure will not have been called yet, and the same is true for older versions as well, because the pytest_namespace hook won't have been called yet as well:

λ pip install pytest==4.0.0 pytest-twisted==1.7.1
...
λ python -c "import pytest; print(pytest.inlineCallbacks)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'pytest' has no attribute 'inlineCallbacks'

@ktdreyer any chance of at least posting the traceback you are getting? I'm curious, it should work for the normal cases where the decorator is being used for test functions.

@ktdreyer
Copy link

ktdreyer commented Jan 9, 2019

sure, here's a job in TravisCI where this failed, before I swiched everything over to @pytest_twisted.inlineCallbacks: https://travis-ci.org/ktdreyer/txkoji/jobs/476977970

TravisCI might garbage-collect the log so I'll paste the relevant part here. This is with the latest pytest from PyPI (4.1.0), and pytest-twisted's master branch.

============================= test session starts ==============================
platform linux2 -- Python 2.7.14, pytest-4.1.0, py-1.7.0, pluggy-0.8.0
rootdir: /home/travis/build/ktdreyer/txkoji, inifile:
plugins: flake8-1.0.2, twisted-1.8
collected 60 items / 8 errors                                                  
==================================== ERRORS ====================================
_________________ ERROR collecting txkoji/tests/test_build.py __________________
txkoji/tests/test_build.py:10: in <module>
    class TestGetBuild(object):
txkoji/tests/test_build.py:42: in TestGetBuild
    @pytest.inlineCallbacks
E   AttributeError: 'module' object has no attribute 'inlineCallbacks'

@nicoddemus
Copy link
Member Author

@ktdreyer thanks! I will try to execute your project tomorrow to see what's going on. 👍

@nicoddemus
Copy link
Member Author

Oh my #51! That explains it! 😅

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.

4 participants