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
68128715
Commit
68128715
authored
Aug 14, 2004
by
Johannes Gijsbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unwrap too-smart loop: we can't use `src` for both hard and symbolic links.
parent
46f14598
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
Lib/test/test_shutil.py
Lib/test/test_shutil.py
+16
-8
No files found.
Lib/test/test_shutil.py
View file @
68128715
...
...
@@ -31,17 +31,25 @@ class TestShutil(unittest.TestCase):
def
test_dont_copy_file_onto_link_to_itself
(
self
):
# bug 851123.
os
.
mkdir
(
TESTFN
)
src
=
os
.
path
.
join
(
TESTFN
,
'cheese'
)
dst
=
os
.
path
.
join
(
TESTFN
,
'shop'
)
src
=
os
.
path
.
join
(
TESTFN
,
'cheese'
)
dst
=
os
.
path
.
join
(
TESTFN
,
'shop'
)
try
:
f
=
open
(
src
,
'w'
)
f
=
open
(
src
,
'w'
)
f
.
write
(
'cheddar'
)
f
.
close
()
for
funcname
in
'link'
,
'symlink'
:
getattr
(
os
,
funcname
)(
src
,
dst
)
self
.
assertRaises
(
shutil
.
Error
,
shutil
.
copyfile
,
src
,
dst
)
self
.
assertEqual
(
open
(
src
,
'r'
).
read
(),
'cheddar'
)
os
.
remove
(
dst
)
os
.
link
(
src
,
dst
)
self
.
assertRaises
(
shutil
.
Error
,
shutil
.
copyfile
,
src
,
dst
)
self
.
assertEqual
(
open
(
src
,
'r'
).
read
(),
'cheddar'
)
os
.
remove
(
dst
)
# Using `src` here would mean we end up with a symlink pointing
# to TESTFN/TESTFN/cheese, while it should point at
# TESTFN/cheese.
os
.
symlink
(
'cheese'
,
dst
)
self
.
assertRaises
(
shutil
.
Error
,
shutil
.
copyfile
,
src
,
dst
)
self
.
assertEqual
(
open
(
src
,
'r'
).
read
(),
'cheddar'
)
os
.
remove
(
dst
)
finally
:
try
:
shutil
.
rmtree
(
TESTFN
)
...
...
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