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
7c85a448
Commit
7c85a448
authored
Oct 23, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure the temporary file is cleaned up even when we raise TestSkipped.
parent
bd97ff8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
+24
-21
Lib/test/test_largefile.py
Lib/test/test_largefile.py
+24
-21
No files found.
Lib/test/test_largefile.py
View file @
7c85a448
...
@@ -14,12 +14,15 @@ import os, struct, stat, sys
...
@@ -14,12 +14,15 @@ import os, struct, stat, sys
# only run if the current system support large files
# only run if the current system support large files
f
=
open
(
test_support
.
TESTFN
,
'w'
)
f
=
open
(
test_support
.
TESTFN
,
'w'
)
try
:
try
:
# 2**31 == 2147483648
# 2**31 == 2147483648
f
.
seek
(
2147483649L
)
f
.
seek
(
2147483649L
)
except
OverflowError
:
except
OverflowError
:
raise
test_support
.
TestSkipped
,
"platform does not have largefile support"
f
.
close
()
os
.
unlink
(
test_support
.
TESTFN
)
raise
test_support
.
TestSkipped
,
\
"platform does not have largefile support"
else
:
else
:
f
.
close
()
f
.
close
()
# create >2GB file (2GB = 2147483648 bytes)
# create >2GB file (2GB = 2147483648 bytes)
...
@@ -31,22 +34,22 @@ name = test_support.TESTFN
...
@@ -31,22 +34,22 @@ name = test_support.TESTFN
# it takes a long time to build the >2GB file and takes >2GB of disk space
# it takes a long time to build the >2GB file and takes >2GB of disk space
# therefore test_support.use_large_resources must be defined to run this test
# therefore test_support.use_large_resources must be defined to run this test
if
sys
.
platform
[:
3
]
==
'win'
and
not
test_support
.
use_large_resources
:
if
sys
.
platform
[:
3
]
==
'win'
and
not
test_support
.
use_large_resources
:
raise
test_support
.
TestSkipped
,
\
raise
test_support
.
TestSkipped
,
\
"test requires %s bytes and a long time to run"
%
str
(
size
)
"test requires %s bytes and a long time to run"
%
str
(
size
)
def
expect
(
got_this
,
expect_this
):
def
expect
(
got_this
,
expect_this
):
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'%s =?= %s ...'
%
(
`got_this`
,
`expect_this`
),
print
'%s =?= %s ...'
%
(
`got_this`
,
`expect_this`
),
if
got_this
!=
expect_this
:
if
got_this
!=
expect_this
:
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'no'
print
'no'
raise
test_support
.
TestFailed
,
'got %s, but expected %s'
%
\
raise
test_support
.
TestFailed
,
'got %s, but expected %s'
%
\
(
str
(
got_this
),
str
(
expect_this
))
(
str
(
got_this
),
str
(
expect_this
))
else
:
else
:
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'yes'
print
'yes'
# test that each file function works as expected for a large (i.e. >2GB, do
# test that each file function works as expected for a large (i.e. >2GB, do
...
@@ -60,14 +63,14 @@ f.write('a')
...
@@ -60,14 +63,14 @@ f.write('a')
f
.
flush
()
f
.
flush
()
expect
(
os
.
fstat
(
f
.
fileno
())[
stat
.
ST_SIZE
],
size
+
1
)
expect
(
os
.
fstat
(
f
.
fileno
())[
stat
.
ST_SIZE
],
size
+
1
)
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'check file size with os.fstat'
print
'check file size with os.fstat'
f
.
close
()
f
.
close
()
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'check file size with os.stat'
print
'check file size with os.stat'
expect
(
os
.
stat
(
name
)[
stat
.
ST_SIZE
],
size
+
1
)
expect
(
os
.
stat
(
name
)[
stat
.
ST_SIZE
],
size
+
1
)
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'play around with seek() and read() with the built largefile'
print
'play around with seek() and read() with the built largefile'
f
=
open
(
name
,
'r'
)
f
=
open
(
name
,
'r'
)
expect
(
f
.
tell
(),
0
)
expect
(
f
.
tell
(),
0
)
expect
(
f
.
read
(
1
),
'
\
000
'
)
expect
(
f
.
read
(
1
),
'
\
000
'
)
...
@@ -96,7 +99,7 @@ expect(f.read(1), 'a') # the 'a' that was written at the end of the file above
...
@@ -96,7 +99,7 @@ expect(f.read(1), 'a') # the 'a' that was written at the end of the file above
f
.
close
()
f
.
close
()
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'play around with os.lseek() with the built largefile'
print
'play around with os.lseek() with the built largefile'
f
=
open
(
name
,
'r'
)
f
=
open
(
name
,
'r'
)
expect
(
os
.
lseek
(
f
.
fileno
(),
0
,
0
),
0
)
expect
(
os
.
lseek
(
f
.
fileno
(),
0
,
0
),
0
)
expect
(
os
.
lseek
(
f
.
fileno
(),
42
,
0
),
42
)
expect
(
os
.
lseek
(
f
.
fileno
(),
42
,
0
),
42
)
...
@@ -126,4 +129,4 @@ f.close()
...
@@ -126,4 +129,4 @@ f.close()
## pass
## pass
os
.
unlink
(
name
)
os
.
unlink
(
name
)
print
>>
sys
.
stderr
,
name
,
"exists:"
,
os
.
path
.
exists
(
name
)
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