Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
cc179ffe
Commit
cc179ffe
authored
Aug 31, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#22315: Add test to capture the failure.
parent
c73fc06c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
tests/test_dir_util.py
tests/test_dir_util.py
+29
-0
No files found.
tests/test_dir_util.py
View file @
cc179ffe
...
@@ -3,7 +3,9 @@ import unittest
...
@@ -3,7 +3,9 @@ import unittest
import
os
import
os
import
stat
import
stat
import
sys
import
sys
import
contextlib
from
distutils
import
dir_util
,
errors
from
distutils.dir_util
import
(
mkpath
,
remove_tree
,
create_tree
,
copy_tree
,
from
distutils.dir_util
import
(
mkpath
,
remove_tree
,
create_tree
,
copy_tree
,
ensure_relative
)
ensure_relative
)
...
@@ -11,6 +13,20 @@ from distutils import log
...
@@ -11,6 +13,20 @@ from distutils import log
from
distutils.tests
import
support
from
distutils.tests
import
support
from
test.support
import
run_unittest
from
test.support
import
run_unittest
@
contextlib
.
context_manager
def
patch_obj
(
obj
,
attr
,
replacement
):
"""
A poor man's mock.patch.object
"""
orig
=
getattr
(
obj
,
attr
)
try
:
setattr
(
obj
,
attr
,
replacement
)
yield
finally
:
setattr
(
obj
,
attr
,
orig
)
class
DirUtilTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
class
DirUtilTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
def
_log
(
self
,
msg
,
*
args
):
def
_log
(
self
,
msg
,
*
args
):
...
@@ -119,6 +135,19 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -119,6 +135,19 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
self
.
assertEqual
(
ensure_relative
(
'c:
\
\
home
\
\
foo'
),
'c:home
\
\
foo'
)
self
.
assertEqual
(
ensure_relative
(
'c:
\
\
home
\
\
foo'
),
'c:home
\
\
foo'
)
self
.
assertEqual
(
ensure_relative
(
'home
\
\
foo'
),
'home
\
\
foo'
)
self
.
assertEqual
(
ensure_relative
(
'home
\
\
foo'
),
'home
\
\
foo'
)
def
test_copy_tree_exception_in_listdir
(
self
):
"""
An exception in listdir should raise a DistutilsFileError
"""
def
new_listdir
(
path
):
raise
OSError
()
# simulate a transient network error or other failure invoking listdir
with
patch_obj
(
os
,
'listdir'
,
new_listdir
):
args
=
'src'
,
None
exc
=
errors
.
DistutilsFileError
self
.
assertRaises
(
exc
,
dir_util
.
copy_tree
,
*
args
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
DirUtilTestCase
)
return
unittest
.
makeSuite
(
DirUtilTestCase
)
...
...
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