Lemmons / pytest-raises

An implementation of pytest.raises as a pytest.mark fixture
MIT License
19 stars 8 forks source link

Compatibility with pytest 3.6+ #11

Closed AetherUnbound closed 6 years ago

AetherUnbound commented 6 years ago

I recently got the following deprecation warning when using pytest-raises with the latest pytest:

/home/mattb/git/airflow/airflow-wrappers/venv/x3/lib/python3.6/site-packages/pytest_raises/pytest_raises.py:20: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
  exception = raises_marker.kwargs.get('exception')
/home/mattb/git/airflow/airflow-wrappers/venv/x3/lib/python3.6/site-packages/pytest_raises/pytest_raises.py:22: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
Please use node.get_closest_marker(name) or node.iter_markers(name).
Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
  message = raises_marker.kwargs.get('message')

Pytest version:

 mattb  (e) airflow-wrappers   feature/MDA-111-wrapper-trigger-per-cell-dags  ~  git  airflow  airflow-wrappers  pytest --version
This is pytest version 3.6.0, imported from /home/mattb/programs/anaconda3/envs/airflow-wrappers/lib/python3.6/site-packages/pytest.py
setuptools registered plugins:
  pytest-raises-0.8 at /home/mattb/programs/anaconda3/envs/airflow-wrappers/lib/python3.6/site-packages/pytest_raises/pytest_raises.py

Pytest has a guide for upgrading markers, which is what I followed: https://docs.pytest.org/en/latest/mark.html#updating-code

All unit tests passed on my local machine, let me know if there's anything else I need to add!

AetherUnbound commented 6 years ago

I'll look into why the build is failing.

Lemmons commented 6 years ago

Thanks for the PR. Looks like failures are for python versions greater than 3.5, which are only using pytest 3.3 for some reason. I'd suggest updating the pytest version in setup.py to >=3.6.0 and try again.

AetherUnbound commented 6 years ago

Thanks @Lemmons! I hate to hurt compatibility, are you comfortable with me bumping the pytest requirement? Alternatively, I could do a check to see if item has the get_closest_marker method and prefer that over get_marker. That would allow pytest-raises to still be compatible with pytest<3.5.

Lemmons commented 6 years ago

That is fine with me. I usually feel like we should be using the latest test tools possible, but I also understand that that often isn't the case.

AetherUnbound commented 6 years ago

I tend to agree, but I don't mind adding backwards compatibility here :)

Lemmons commented 6 years ago

Thanks again. This has been released as pytest-raises 0.9

AetherUnbound commented 6 years ago

No way! Thanks for the super quick response!