-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
TypeError in test collection when sys.stdin isn't an iterator #3314
Comments
GitMate.io thinks possibly related issues are #3251 (Warnings not captured during test collection), #2532 (TypeError on conftest.py during collection), #33 (TypeError when module under test or function under test is named 'test'), #1976 (please don't suppress tracebacks on ImportError during test collection), and #149 (Distributed testing silently ignores collection errors). |
I thought maybe adding
but it didn't:
|
Here's the code where csv.reader detects an iterator. It uses PyObject_GetIter, which according to the docs is equivalent to Aha! and |
This patch fixes the failure:
It does it by making DontReadFromInput an iterable and only raising the OSError when something attempts to consume the iterator. |
In this build, I found that because of the construction of a
csv.DictReader(sys.stdin)
during import, the file can't be collected.Looking a
--pdb
trace on it, I see:Obviously, I could refactor the code to bypass the error, but since the code runs, I feel it should be supported for pytest collection.
Perhaps
DontReadFromInput
could be adapted to be an iterator to satisfy csv.DictReader.The issue can be minimally replicated with
The text was updated successfully, but these errors were encountered: