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
4590c00e
Commit
4590c00e
authored
Nov 01, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_on_error(): Rewrite so it works on WinXP too. Unsure about 95/98/ME.
parent
e2d59184
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
Lib/test/test_shutil.py
Lib/test/test_shutil.py
+13
-7
No files found.
Lib/test/test_shutil.py
View file @
4590c00e
# Copyright (C) 2003 Python Software Foundation
import
unittest
...
...
@@ -20,21 +19,28 @@ class TestShutil(unittest.TestCase):
def
test_on_error
(
self
):
self
.
errorState
=
0
os
.
mkdir
(
TESTFN
)
f
=
open
(
os
.
path
.
join
(
TESTFN
,
'a'
),
'w'
)
self
.
childpath
=
os
.
path
.
join
(
TESTFN
,
'a'
)
f
=
open
(
self
.
childpath
,
'w'
)
f
.
close
()
# Make TESTFN unwritable.
os
.
chmod
(
TESTFN
,
stat
.
S_IRUSR
)
old_dir_mode
=
os
.
stat
(
TESTFN
).
st_mode
old_child_mode
=
os
.
stat
(
self
.
childpath
).
st_mode
# Make unwritable.
os
.
chmod
(
self
.
childpath
,
stat
.
S_IREAD
)
os
.
chmod
(
TESTFN
,
stat
.
S_IREAD
)
shutil
.
rmtree
(
TESTFN
,
onerror
=
self
.
check_args_to_onerror
)
# Make TESTFN writable again.
os
.
chmod
(
TESTFN
,
stat
.
S_IRWXU
)
# Make writable again.
os
.
chmod
(
TESTFN
,
old_dir_mode
)
os
.
chmod
(
self
.
childpath
,
old_child_mode
)
# Clean up.
shutil
.
rmtree
(
TESTFN
)
def
check_args_to_onerror
(
self
,
func
,
arg
,
exc
):
if
self
.
errorState
==
0
:
self
.
assertEqual
(
func
,
os
.
remove
)
self
.
assertEqual
(
arg
,
os
.
path
.
join
(
TESTFN
,
'a'
)
)
self
.
assertEqual
(
arg
,
self
.
childpath
)
self
.
assertEqual
(
exc
[
0
],
OSError
)
self
.
errorState
=
1
else
:
...
...
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