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
unittest loader.py TypeError when code directory contains a socket #69507
Comments
Hi, when trying to run tests after upgrading from Python 3.4 to Python 3.5 I encountered the following exception: Traceback (most recent call last):
...
File "/usr/lib/python3.5/unittest/loader.py", line 341, in discover
tests = list(self._find_tests(start_dir, pattern))
File "/usr/lib/python3.5/unittest/loader.py", line 398, in _find_tests
full_path, pattern, namespace)
TypeError: 'NoneType' object is not iterable This was caused by a stray socket in my code directory, and the fact that _find_test_path only considers directories and regular files. I attached a suggested fix that just skips all special files. No tests other than "it works on my machine". |
The fix is appropriate (we might want to think about symlinks in the future). I'd very much like a test for it (in Lib/unittest/test/test_discovery.py) and it should be applied to 3.5, master - older versions had this wrapped up in simpler code and won't fail like this. |
patch-with-test.patch is a patch against current tip (c3cec0f77eff+). It applies cleanly to 3.5. It seemed simplest to include the socket in test_find_tests. |
Alternatively, patch-with-seperate-test.patch creates a seperate function to test for this issue. |
Ping |
The fix looks ok, however the test seem to contain unnecessary code and it duplicates most of the previous test. |
New changeset efc9836e0c83 by Robert Collins in branch '3.5': |
New changeset 1d72402c1c91 by Robert Collins in branch 'default': |
Thanks for the patch; the test may be redundant but not enough to matter for now - and the bug really doth need fixing, so I've applied it as-is. |
Just as a side note, the patch also works for soft links that point to files that don't exist. Thanks for getting this fixed! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: