Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ecd53838
Commit
ecd53838
authored
Mar 15, 2016
by
Robert Collins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#25320: Handle sockets in directories unittest discovery is scanning.
Patch from Victor van den Elzen.
parent
87d6e136
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
0 deletions
+46
-0
Lib/unittest/loader.py
Lib/unittest/loader.py
+2
-0
Lib/unittest/test/test_discovery.py
Lib/unittest/test/test_discovery.py
+40
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/loader.py
View file @
ecd53838
...
...
@@ -479,6 +479,8 @@ class TestLoader(object):
return
tests
,
True
finally
:
self
.
_loading_packages
.
discard
(
name
)
else
:
return
None
,
False
defaultTestLoader
=
TestLoader
()
...
...
Lib/unittest/test/test_discovery.py
View file @
ecd53838
...
...
@@ -90,6 +90,46 @@ class TestDiscovery(unittest.TestCase):
(
'test3'
,
'test4'
)])
self
.
assertEqual
(
suite
,
expected
)
def
test_find_tests_socket
(
self
):
# A socket is neither a directory nor a regular file.
# https://bugs.python.org/issue25320
loader
=
unittest
.
TestLoader
()
original_listdir
=
os
.
listdir
def
restore_listdir
():
os
.
listdir
=
original_listdir
original_isfile
=
os
.
path
.
isfile
def
restore_isfile
():
os
.
path
.
isfile
=
original_isfile
original_isdir
=
os
.
path
.
isdir
def
restore_isdir
():
os
.
path
.
isdir
=
original_isdir
path_lists
=
[[
'socket'
]]
os
.
listdir
=
lambda
path
:
path_lists
.
pop
(
0
)
self
.
addCleanup
(
restore_listdir
)
os
.
path
.
isdir
=
lambda
path
:
False
self
.
addCleanup
(
restore_isdir
)
os
.
path
.
isfile
=
lambda
path
:
False
self
.
addCleanup
(
restore_isfile
)
loader
.
_get_module_from_name
=
lambda
path
:
path
+
' module'
orig_load_tests
=
loader
.
loadTestsFromModule
def
loadTestsFromModule
(
module
,
pattern
=
None
):
# This is where load_tests is called.
base
=
orig_load_tests
(
module
,
pattern
=
pattern
)
return
base
+
[
module
+
' tests'
]
loader
.
loadTestsFromModule
=
loadTestsFromModule
loader
.
suiteClass
=
lambda
thing
:
thing
top_level
=
os
.
path
.
abspath
(
'/foo'
)
loader
.
_top_level_dir
=
top_level
suite
=
list
(
loader
.
_find_tests
(
top_level
,
'test*.py'
))
self
.
assertEqual
(
suite
,
[])
def
test_find_tests_with_package
(
self
):
loader
=
unittest
.
TestLoader
()
...
...
Misc/ACKS
View file @
ecd53838
...
...
@@ -393,6 +393,7 @@ Lance Ellinghaus
Daniel Ellis
Phil Elson
David Ely
Victor van den Elzen
Jeff Epler
Tom Epperly
Gökcen Eraslan
...
...
Misc/NEWS
View file @
ecd53838
...
...
@@ -91,6 +91,9 @@ Core and Builtins
Library
-------
- Issue #25320: Handle sockets in directories unittest discovery is scanning.
Patch from Victor van den Elzen.
- Issue #16181: cookiejar.http2time() now returns None if year is higher than
datetime.MAXYEAR.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment