Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
aec09788
Commit
aec09788
authored
May 10, 2013
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suppress Py3k resource warnings files from 'open()'.
parent
56319ef6
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
150 deletions
+154
-150
src/ZEO/tests/testConnection.py
src/ZEO/tests/testConnection.py
+2
-1
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+119
-109
src/ZEO/tests/testZEOOptions.py
src/ZEO/tests/testZEOOptions.py
+2
-3
src/ZEO/tests/test_cache.py
src/ZEO/tests/test_cache.py
+31
-37
No files found.
src/ZEO/tests/testConnection.py
View file @
aec09788
...
@@ -231,7 +231,8 @@ This tests tries to provoke this bug by:
...
@@ -231,7 +231,8 @@ This tests tries to provoke this bug by:
... print(record.name, record.levelname, end=' ')
... print(record.name, record.levelname, end=' ')
... print(handler.format(record))
... print(handler.format(record))
... if bad:
... if bad:
... print(open('server-%s.log' % addr[1]).read())
... with open('server-%s.log' % addr[1]) as f:
... print(f.read())
... #else:
... #else:
... # logging.getLogger('ZEO').debug('GOOD %s' % c)
... # logging.getLogger('ZEO').debug('GOOD %s' % c)
... db.close()
... db.close()
...
...
src/ZEO/tests/testZEO.py
View file @
aec09788
This diff is collapsed.
Click to expand it.
src/ZEO/tests/testZEOOptions.py
View file @
aec09788
...
@@ -46,9 +46,8 @@ class TestZEOOptions(TestZDOptions):
...
@@ -46,9 +46,8 @@ class TestZEOOptions(TestZDOptions):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
tempfilename
=
tempfile
.
mktemp
()
self
.
tempfilename
=
tempfile
.
mktemp
()
f
=
open
(
self
.
tempfilename
,
"w"
)
with
open
(
self
.
tempfilename
,
"w"
)
as
f
:
f
.
write
(
self
.
configdata
)
f
.
write
(
self
.
configdata
)
f
.
close
()
def
tearDown
(
self
):
def
tearDown
(
self
):
try
:
try
:
...
...
src/ZEO/tests/test_cache.py
View file @
aec09788
...
@@ -159,11 +159,10 @@ class CacheTests(ZODB.tests.util.TestCase):
...
@@ -159,11 +159,10 @@ class CacheTests(ZODB.tests.util.TestCase):
path
=
tempfile
.
mktemp
()
path
=
tempfile
.
mktemp
()
# Copy data from self.cache into path, reaching into the cache
# Copy data from self.cache into path, reaching into the cache
# guts to make the copy.
# guts to make the copy.
dst
=
open
(
path
,
"wb+"
)
with
open
(
path
,
"wb+"
)
as
dst
:
src
=
self
.
cache
.
f
src
=
self
.
cache
.
f
src
.
seek
(
0
)
src
.
seek
(
0
)
dst
.
write
(
src
.
read
(
self
.
cache
.
maxsize
))
dst
.
write
(
src
.
read
(
self
.
cache
.
maxsize
))
dst
.
close
()
copy
=
ZEO
.
cache
.
ClientCache
(
path
)
copy
=
ZEO
.
cache
.
ClientCache
(
path
)
# Verify that internals of both objects are the same.
# Verify that internals of both objects are the same.
...
@@ -213,24 +212,22 @@ class CacheTests(ZODB.tests.util.TestCase):
...
@@ -213,24 +212,22 @@ class CacheTests(ZODB.tests.util.TestCase):
cache
.
close
()
cache
.
close
()
def
testConversionOfLargeFreeBlocks
(
self
):
def
testConversionOfLargeFreeBlocks
(
self
):
f
=
open
(
'cache'
,
'wb'
)
with
open
(
'cache'
,
'wb'
)
as
f
:
f
.
write
(
ZEO
.
cache
.
magic
+
f
.
write
(
ZEO
.
cache
.
magic
+
b'
\
0
'
*
8
+
b'
\
0
'
*
8
+
b'f'
+
struct
.
pack
(
">I"
,
(
1
<<
32
)
-
12
)
b'f'
+
struct
.
pack
(
">I"
,
(
1
<<
32
)
-
12
)
)
)
f
.
seek
((
1
<<
32
)
-
1
)
f
.
seek
((
1
<<
32
)
-
1
)
f
.
write
(
b'x'
)
f
.
write
(
b'x'
)
f
.
close
()
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
.
close
()
cache
.
close
()
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
.
close
()
cache
.
close
()
f
=
open
(
'cache'
,
'rb'
)
with
open
(
'cache'
,
'rb'
)
as
f
:
f
.
seek
(
12
)
f
.
seek
(
12
)
self
.
assertEquals
(
f
.
read
(
1
),
b'f'
)
self
.
assertEquals
(
f
.
read
(
1
),
b'f'
)
self
.
assertEquals
(
struct
.
unpack
(
">I"
,
f
.
read
(
4
))[
0
],
self
.
assertEquals
(
struct
.
unpack
(
">I"
,
f
.
read
(
4
))[
0
],
ZEO
.
cache
.
max_block_size
)
ZEO
.
cache
.
max_block_size
)
f
.
close
()
if
not
sys
.
platform
.
startswith
(
'linux'
):
if
not
sys
.
platform
.
startswith
(
'linux'
):
# On platforms without sparse files, these tests are just way
# On platforms without sparse files, these tests are just way
...
@@ -347,8 +344,8 @@ isn't corrupted. To see this, we'll write a little script that
...
@@ -347,8 +344,8 @@ isn't corrupted. To see this, we'll write a little script that
writes records to a cache file repeatedly.
writes records to a cache file repeatedly.
>>> import os, random, sys, time
>>> import os, random, sys, time
>>> with open('t', 'w') as f
ile
:
>>> with open('t', 'w') as f:
... _ = f
ile
.write('''
... _ = f.write('''
... import os, random, sys, time
... import os, random, sys, time
... try:
... try:
... import thread
... import thread
...
@@ -1088,8 +1085,8 @@ def rename_bad_cache_file():
...
@@ -1088,8 +1085,8 @@ def rename_bad_cache_file():
"""
"""
An attempt to open a bad cache file will cause it to be dropped and recreated.
An attempt to open a bad cache file will cause it to be dropped and recreated.
>>> with open('cache', 'w') as f
ile
:
>>> with open('cache', 'w') as f:
... _ = f
ile
.write('x'*100)
... _ = f.write('x'*100)
>>> import logging, sys
>>> import logging, sys
>>> handler = logging.StreamHandler(sys.stdout)
>>> handler = logging.StreamHandler(sys.stdout)
>>> logging.getLogger().addHandler(handler)
>>> logging.getLogger().addHandler(handler)
...
@@ -1104,14 +1101,13 @@ An attempt to open a bad cache file will cause it to be dropped and recreated.
...
@@ -1104,14 +1101,13 @@ An attempt to open a bad cache file will cause it to be dropped and recreated.
>>> cache.store(p64(1), p64(1), None, b'data')
>>> cache.store(p64(1), p64(1), None, b'data')
>>> cache.close()
>>> cache.close()
>>>
f = open('cache')
>>>
with open('cache') as f:
>>>
_ = f.seek(0, 2)
...
_ = f.seek(0, 2)
>>>
print(f.tell())
...
print(f.tell())
1000
1000
>>> f.close()
>>> with open('cache', 'w') as f
ile
:
>>> with open('cache', 'w') as f:
... _ = f
ile
.write('x'*200)
... _ = f.write('x'*200)
>>> cache = ZEO.cache.ClientCache('cache', 1000) # doctest: +ELLIPSIS
>>> cache = ZEO.cache.ClientCache('cache', 1000) # doctest: +ELLIPSIS
Removing bad cache file: 'cache' (prev bad exists).
Removing bad cache file: 'cache' (prev bad exists).
Traceback (most recent call last):
Traceback (most recent call last):
...
@@ -1120,17 +1116,15 @@ An attempt to open a bad cache file will cause it to be dropped and recreated.
...
@@ -1120,17 +1116,15 @@ An attempt to open a bad cache file will cause it to be dropped and recreated.
>>> cache.store(p64(1), p64(1), None, b'data')
>>> cache.store(p64(1), p64(1), None, b'data')
>>> cache.close()
>>> cache.close()
>>>
f = open('cache')
>>>
with open('cache') as f:
>>>
_ = f.seek(0, 2)
...
_ = f.seek(0, 2)
>>>
print(f.tell())
...
print(f.tell())
1000
1000
>>> f.close()
>>>
f = open('cache.bad')
>>>
with open('cache.bad') as f:
>>>
_ = f.seek(0, 2)
...
_ = f.seek(0, 2)
>>>
print(f.tell())
...
print(f.tell())
100
100
>>> f.close()
>>> logging.getLogger().removeHandler(handler)
>>> logging.getLogger().removeHandler(handler)
>>> logging.getLogger().setLevel(old_level)
>>> logging.getLogger().setLevel(old_level)
...
...
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