Fix pytest.mark.parametrize when the argvalue is an iterator#5356
Conversation
|
Thanks @asottile ! If I understand correctly, we were consuming the generator when checking for parametrization arguments to ignore at first so when the real parametrization kicked in there was nothing left for the parameters, right? |
that is exactly right :D |
Codecov Report
@@ Coverage Diff @@
## master #5356 +/- ##
=========================================
- Coverage 95.32% 94.2% -1.12%
=========================================
Files 115 115
Lines 26384 26391 +7
Branches 2607 2607
=========================================
- Hits 25150 24862 -288
- Misses 924 1219 +295
Partials 310 310
Continue to review full report at Codecov.
|
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @asottile!
Please open the backport PR after this gets merged. 👍
|
The procedure I used here was: git checkout origin/4.6-maintenance -b backport_5356
git cherry-pick ... |
|
@asottile @nicoddemus |
|
this pr doenst test critical cases in, and it should fail on iterators |
| yield 2 | ||
| yield 3 | ||
|
|
||
| @pytest.mark.parametrize('a', gen()) |
There was a problem hiding this comment.
this breaks down on marker/generator reuse
There was a problem hiding this comment.
@RonnyPfannschmidt please consider creating a new issue - or do you know what's up with the comment, @asottile ?
There was a problem hiding this comment.
I think @RonnyPfannschmidt is suggesting this won't work (not at a computer)
m = pytest.mark.parametrize('a', gen())
@m
def test1(a): pass
@m
def test2(a): passThere was a problem hiding this comment.
But if it doesn't, it never worked so 🤷♂️ probably?
There was a problem hiding this comment.
we already had a issue about reuse of generators
There was a problem hiding this comment.
yeah that example above is indeed broken, but wasn't the regression being targetted by this fix:
$ pytest t.py -vv
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.5.0, py-1.8.0, pluggy-0.12.0 -- /tmp/venv/bin/python3
cachedir: .pytest_cache
rootdir: /tmp
plugins: celery-4.3.0
collected 4 items
t.py::test1[1] PASSED [ 25%]
t.py::test1[2] PASSED [ 50%]
t.py::test1[3] PASSED [ 75%]
t.py::test2[a0] SKIPPED [100%]
===================== 3 passed, 1 skipped in 0.01 seconds ======================
Agreed, I had the same idea yesterday. 👍 |
|
Let's not lose track of "did we backport this?" let's replace the label when competed with a backported label |
|
Ok. We should/could also do backports in batches then - resulting in a single CI run, instead of one for every backport. |
|
Agree with having a label: it is easy to see the labels when listing the PRs. 👍 |
Resolves #5354