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
d1795705
Commit
d1795705
authored
Aug 17, 2001
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test that uu.py will not override an existing file if out_file isn't
given and the path is gleaned from the uu header.
parent
59dae8ad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
Lib/test/test_uu.py
Lib/test/test_uu.py
+34
-0
No files found.
Lib/test/test_uu.py
View file @
d1795705
...
...
@@ -122,3 +122,37 @@ try:
raise
TestFailed
(
"No exception thrown"
)
except
uu
.
Error
,
e
:
verify
(
str
(
e
)
==
'No valid begin line found in input file'
)
# Test to verify that decode() will refuse to overwrite an existing file
import
tempfile
outfile
=
tempfile
.
mktemp
()
inp
=
StringIO
(
'Here is a message to be uuencoded'
)
out
=
StringIO
()
uu
.
encode
(
inp
,
out
,
outfile
)
out
.
seek
(
0
)
try
:
if
verbose
:
print
'9. decode w/file not exists is okay'
uu
.
decode
(
out
)
if
not
os
.
path
.
exists
(
outfile
):
raise
TestFailed
(
'uudecode w/ out_file=None failed'
)
fp
=
open
(
outfile
)
data
=
fp
.
read
()
fp
.
close
()
if
data
<>
inp
.
getvalue
():
raise
TestFailed
(
'uudecode stored something weird'
)
# Try to write it again, which should cause a failure
if
verbose
:
print
'10. uudecode w/file exists fails'
out
.
seek
(
0
)
try
:
uu
.
decode
(
out
)
except
uu
.
Error
:
pass
else
:
raise
TestFailed
(
'expected to get a "file exists" error'
)
finally
:
try
:
os
.
unlink
(
outfile
)
except
OSError
:
pass
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