-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
allow to pass argvalues as an iterator to pytest.mark.parametrize() #122
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
Comments
Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt): i noticed a deeper issue, just consuming the map object will break parametrizing anything that reuses it |
Original comment by Rafał Stożek (BitBucket: rafales, GitHub: rafales): For anyone who will have the same issue: if you pass results of zip(), map(), range(), filter() etc. to a marker like parametrize make sure you wrap it in a list() call like this:
because in python 3 those methods return a generator instead of a list. |
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): pytest-trunk already handles the case when you use map/zip/range/filter in parametrize but as @RonnyPfannschmidt points out, if you apply the same marker instance multiple times you'll get a "skip" on the second application because the iterator is exhausted. I guess parametrize() should explode the values early on to avoid this issue. |
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): While params in |
@hpk42 and @RonnyPfannschmidt, this works for me in Python 3.4 with the latest import pytest
pp = pytest.mark.parametrize('i', range(3))
@pp
def test_foo(i):
pass
@pp
def test_bar(i):
pass
I couldn't find anything in the CHANGELOG mentioning this issue. Is this still an issue, or can we close this? |
it still fails with examples like this:
|
@nicoddemus unlike general iterators, like for example map/imap objects, a range can be consumed multiple times |
@RonnyPfannschmidt oh I didn't know that, thanks! |
Closing this one, as its messy to support and a actual user error, perhaps there should be a warning for non-sequences? |
---- ci: Test against Python 3.7 ---- ci: Skip Coveralls submission if COVERALLS_REPO_TOKEN env. var is empty ---- ci: Update circleci image to allow install of python 3.7 See https://circleci.com/docs/2.0/configuration-reference/#machine ---- pytest-server-fixture: Fix rethinkdb tests requiring rethinkdb < 2.4.0 The current implementation needs to be refactored to support the latest release of rethinkdb-python package. See pytest-dev#132 ---- wheels: Generate universal wheels installable with both python 2.x and 3.x See pytest-dev#125 Fix DeprecationWarning warnings using "logger.warning()" function ---- pytest-virtualenv: Add virtualenv as install requirement. Fixes pytest-dev#122 Remove requirement for pytest<4.0.0 See pytest-dev#100 ---- pytest-webdriver: Fix RemovedInPytest4Warning using getfixturevalue This commit fixes the following error: > root_uri.append(request.getfuncargvalue('pyramid_server').uri) E RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue pytest_webdriver.py:62: RemovedInPytest4Warning See pytest-dev#100 ---- pytest-verbose-parametrize: Add support for revamped marker infrastructure This commit fixes tests failing with pytest > 4.0.0 ---- pytest-verbose-parametrize: Fix integration tests to support pytest >= 4.1.0 This commit updates tests to support version of pytest with pytest-dev/pytest@e9b2475e2 (Display actual test ids in `--collect-only`) ---- dist: Remove support for building and distributing *.egg files Wheel is currently considered the standard for built and binary packaging for Python See https://packaging.python.org/discussions/wheel-vs-egg/ See pytest-dev#125 ---- VagrantFile: Install python 3.7 and initialize python 3.7 by default
Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)
The text was updated successfully, but these errors were encountered: