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

Multiple calls to parametrize result in empty value lists not skipping the test #510

Closed
pytestbot opened this issue May 5, 2014 · 3 comments · Fixed by tjamet/caduc#4
Closed
Assignees
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Alex Stapleton (BitBucket: private, GitHub: private)


If you call parametrize on a test more than once for different arguments of the test it doesn't seem to combine the parameters correctly if some of them are empty. This results in tests that would normally get skipped because their parametisation is missing values receiving the internal _notset sentinel object for that fixture.

Examples here https://gist.github.com/public/e671a53b70fbb6fb6129

The last example is the simplest reproduction of the problem.

This does not get skipped and fixP is _notset.

@pytest.mark.parametrize(["fixP"], [(1,)])
@pytest.mark.parametrize(["fixQ"], [])
def test_fixA_fixB_bad2(fixP, fixQ):
    print fixP, fixQ

but if you swap the order of the calls to parametrize...

@pytest.mark.parametrize(["fixQ"], [])
@pytest.mark.parametrize(["fixP"], [(1,)])
def test_fixA_fixB_bad2(fixP, fixQ):
    print fixP, fixQ

it skips as you would expect from reading the documentation.

I've reproduced this on 2.5.2 and on the current master 2.6 branch.


@pytestbot
Copy link
Contributor Author

Original comment by Alex Stapleton (BitBucket: private, GitHub: private):


Hey @flub thanks for the suggestion about working around this issue at EuroPython. Will give it a go :)

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
@pfctdayelise pfctdayelise added the topic: parametrize related to @pytest.mark.parametrize label Jul 25, 2015
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Apr 21, 2016
RonnyPfannschmidt added a commit to RonnyPfannschmidt/pytest that referenced this issue Apr 21, 2016
@RonnyPfannschmidt RonnyPfannschmidt added the type: regression indicates a problem that was introduced in a release which was working previously label Apr 24, 2016
@RonnyPfannschmidt
Copy link
Member

i just found a skip thats in place for this, but not being triggered

@RonnyPfannschmidt
Copy link
Member

found the skip reason

callspec copying does not copy the trigger

nicoddemus added a commit that referenced this issue May 30, 2016
fix #510 by adding a describing skip marker on empty parameterize
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jun 6, 2016
2.9.2
=====

**Bug Fixes**

* fix `#510`_: skip tests where one parameterize dimension was empty
  thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR

* Fix Xfail does not work with condition keyword argument.
  Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
  for PR the (`#1524`_).

* Fix win32 path issue when puttinging custom config file with absolute path
  in ``pytest.main("-c your_absolute_path")``.

* Fix maximum recursion depth detection when raised error class is not aware
  of unicode/encoded bytes.
  Thanks `@prusse-martin`_ for the PR (`#1506`_).

* Fix ``pytest.mark.skip`` mark when used in strict mode.
  Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
  showing how to fix the bug.

* Minor improvements and fixes to the documentation.
  Thanks `@omarkohl`_ for the PR.

* Fix ``--fixtures`` to show all fixture definitions as opposed to just
  one per fixture name.
  Thanks to `@hackebrot`_ for the PR.

.. _#510: pytest-dev/pytest#510
.. _#1506: pytest-dev/pytest#1506
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
.. _#1524: https://github.com/pytest-dev/pytest/issue/1524

.. _@prusse-martin: https://github.com/prusse-martin
.. _@astraw38: https://github.com/astraw38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants