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

nested pytest.mark.parametrize ignore mark=xfail or mark=skip #5092

Closed
azrdev opened this Issue Apr 11, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@azrdev
Copy link

azrdev commented Apr 11, 2019

Applying multiple pytest.mark.parametrize decorators to a test function (no fixtures involved) works fine, except for trying to mark=pytest.mark.xfail() some of the parameters:

import pytest

@pytest.mark.parametrize('a', [
    pytest.param('a1'),
    pytest.param('a2', mark=pytest.mark.xfail()),
])
@pytest.mark.parametrize('b', [
    pytest.param('b1'),
    pytest.param('b2', mark=pytest.mark.skip()),
])
def test_foo(a, b):
    pass

Running python3 -m pytest -vvv test.py I'd expect only a1-b1 to succeed, all other combinations to either fail (because no error + xfail) or be skipped. Instead I get 4 times "PASSED".

pip list of the virtual environment you are using

Package    Version
---------- -------
pip        19.0.3 
setuptools 40.8.0 

pytest and operating system versions

pytest 4.4.0
Python 3.7.3
archlinux rolling

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Apr 12, 2019

This is a typo, you want marks=...

Probably also a bug that pytest.param allows arbitrary keyword arguments silently:

@classmethod
def param(cls, *values, **kw):
marks = kw.pop("marks", ())
if isinstance(marks, MarkDecorator):
marks = (marks,)
else:
assert isinstance(marks, (tuple, list, set))
id_ = kw.pop("id", None)
if id_ is not None:
if not isinstance(id_, six.string_types):
raise TypeError(
"Expected id to be a string, got {}: {!r}".format(type(id_), id_)
)
id_ = ascii_escaped(id_)
return cls(values, marks, id_)

@azrdev

This comment has been minimized.

Copy link
Author

azrdev commented Apr 12, 2019

This is a typo, you want marks=...

indeed, sorry & thank you

Probably also a bug that pytest.param allows arbitrary keyword arguments silently:

do you want to have that in a separate issue or keep this one?

@asottile

This comment has been minimized.

Copy link
Member

asottile commented Apr 12, 2019

this is probably fine

M157q added a commit to zdict/zdict that referenced this issue Apr 15, 2019

Update pytest to 4.4.1 (#337)
This PR updates [pytest](https://pypi.org/project/pytest) from **4.4.0** to **4.4.1**.



<details>
  <summary>Changelog</summary>
  
  
   ### 4.4.1
   ```
   =========================

Bug Fixes
---------

- `5031 &lt;https://github.com/pytest-dev/pytest/issues/5031&gt;`_: Environment variables are properly restored when using pytester&#39;s ``testdir`` fixture.


- `5039 &lt;https://github.com/pytest-dev/pytest/issues/5039&gt;`_: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0.


- `5092 &lt;https://github.com/pytest-dev/pytest/issues/5092&gt;`_: Produce a warning when unknown keywords are passed to ``pytest.param(...)``.


- `5098 &lt;https://github.com/pytest-dev/pytest/issues/5098&gt;`_: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used.
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>

bors bot added a commit to rehandalal/therapist that referenced this issue Apr 17, 2019

Merge #67
67: Update pytest to 4.4.1 r=rehandalal a=pyup-bot


This PR updates [pytest](https://pypi.org/project/pytest) from **4.4.0** to **4.4.1**.



<details>
  <summary>Changelog</summary>
  
  
   ### 4.4.1
   ```
   =========================

Bug Fixes
---------

- `5031 &lt;https://github.com/pytest-dev/pytest/issues/5031&gt;`_: Environment variables are properly restored when using pytester&#39;s ``testdir`` fixture.


- `5039 &lt;https://github.com/pytest-dev/pytest/issues/5039&gt;`_: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0.


- `5092 &lt;https://github.com/pytest-dev/pytest/issues/5092&gt;`_: Produce a warning when unknown keywords are passed to ``pytest.param(...)``.


- `5098 &lt;https://github.com/pytest-dev/pytest/issues/5098&gt;`_: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used.
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>



Co-authored-by: pyup-bot <github-bot@pyup.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.