Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
05c7f27d
Commit
05c7f27d
authored
Sep 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mmap test fixes
parent
5576cae7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
from_cpython/Lib/test/test_mmap.py
from_cpython/Lib/test/test_mmap.py
+16
-4
No files found.
from_cpython/Lib/test/test_mmap.py
View file @
05c7f27d
...
@@ -119,7 +119,10 @@ class MmapTests(unittest.TestCase):
...
@@ -119,7 +119,10 @@ class MmapTests(unittest.TestCase):
def
test_access_parameter
(
self
):
def
test_access_parameter
(
self
):
# Test for "access" keyword parameter
# Test for "access" keyword parameter
mapsize
=
10
mapsize
=
10
open
(
TESTFN
,
"wb"
).
write
(
"a"
*
mapsize
)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("a"*mapsize)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"a"
*
mapsize
)
f
=
open
(
TESTFN
,
"rb"
)
f
=
open
(
TESTFN
,
"rb"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
access
=
mmap
.
ACCESS_READ
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
access
=
mmap
.
ACCESS_READ
)
self
.
assertEqual
(
m
[:],
'a'
*
mapsize
,
"Readonly memory map data incorrect."
)
self
.
assertEqual
(
m
[:],
'a'
*
mapsize
,
"Readonly memory map data incorrect."
)
...
@@ -538,7 +541,10 @@ class MmapTests(unittest.TestCase):
...
@@ -538,7 +541,10 @@ class MmapTests(unittest.TestCase):
@
unittest
.
skipUnless
(
hasattr
(
mmap
,
'PROT_READ'
),
"needs mmap.PROT_READ"
)
@
unittest
.
skipUnless
(
hasattr
(
mmap
,
'PROT_READ'
),
"needs mmap.PROT_READ"
)
def
test_prot_readonly
(
self
):
def
test_prot_readonly
(
self
):
mapsize
=
10
mapsize
=
10
open
(
TESTFN
,
"wb"
).
write
(
"a"
*
mapsize
)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("a"*mapsize)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"a"
*
mapsize
)
f
=
open
(
TESTFN
,
"rb"
)
f
=
open
(
TESTFN
,
"rb"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
prot
=
mmap
.
PROT_READ
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
prot
=
mmap
.
PROT_READ
)
self
.
assertRaises
(
TypeError
,
m
.
write
,
"foo"
)
self
.
assertRaises
(
TypeError
,
m
.
write
,
"foo"
)
...
@@ -550,7 +556,10 @@ class MmapTests(unittest.TestCase):
...
@@ -550,7 +556,10 @@ class MmapTests(unittest.TestCase):
def
test_io_methods
(
self
):
def
test_io_methods
(
self
):
data
=
"0123456789"
data
=
"0123456789"
open
(
TESTFN
,
"wb"
).
write
(
"x"
*
len
(
data
))
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("x"*len(data))
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"x"
*
len
(
data
))
f
=
open
(
TESTFN
,
"r+b"
)
f
=
open
(
TESTFN
,
"r+b"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
len
(
data
))
m
=
mmap
.
mmap
(
f
.
fileno
(),
len
(
data
))
f
.
close
()
f
.
close
()
...
@@ -617,7 +626,10 @@ class MmapTests(unittest.TestCase):
...
@@ -617,7 +626,10 @@ class MmapTests(unittest.TestCase):
m
.
close
()
m
.
close
()
# Should not crash (Issue 5385)
# Should not crash (Issue 5385)
open
(
TESTFN
,
"wb"
).
write
(
"x"
*
10
)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("x"*10)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"x"
*
10
)
f
=
open
(
TESTFN
,
"r+b"
)
f
=
open
(
TESTFN
,
"r+b"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
0
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
0
)
f
.
close
()
f
.
close
()
...
...
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