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:
... print(record.name, record.levelname, end=' ')
... print(handler.format(record))
... if bad:
... print(open('server-%s.log' % addr[1]).read())
... with open('server-%s.log' % addr[1]) as f:
... print(f.read())
... #else:
... # logging.getLogger('ZEO').debug('GOOD %s' % c)
... 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):
def
setUp
(
self
):
self
.
tempfilename
=
tempfile
.
mktemp
()
f
=
open
(
self
.
tempfilename
,
"w"
)
f
.
write
(
self
.
configdata
)
f
.
close
()
with
open
(
self
.
tempfilename
,
"w"
)
as
f
:
f
.
write
(
self
.
configdata
)
def
tearDown
(
self
):
try
:
...
...
src/ZEO/tests/test_cache.py
View file @
aec09788
...
...
@@ -159,11 +159,10 @@ class CacheTests(ZODB.tests.util.TestCase):
path
=
tempfile
.
mktemp
()
# Copy data from self.cache into path, reaching into the cache
# guts to make the copy.
dst
=
open
(
path
,
"wb+"
)
src
=
self
.
cache
.
f
src
.
seek
(
0
)
dst
.
write
(
src
.
read
(
self
.
cache
.
maxsize
))
dst
.
close
()
with
open
(
path
,
"wb+"
)
as
dst
:
src
=
self
.
cache
.
f
src
.
seek
(
0
)
dst
.
write
(
src
.
read
(
self
.
cache
.
maxsize
))
copy
=
ZEO
.
cache
.
ClientCache
(
path
)
# Verify that internals of both objects are the same.
...
...
@@ -213,24 +212,22 @@ class CacheTests(ZODB.tests.util.TestCase):
cache
.
close
()
def
testConversionOfLargeFreeBlocks
(
self
):
f
=
open
(
'cache'
,
'wb'
)
f
.
write
(
ZEO
.
cache
.
magic
+
b'
\
0
'
*
8
+
b'f'
+
struct
.
pack
(
">I"
,
(
1
<<
32
)
-
12
)
)
f
.
seek
((
1
<<
32
)
-
1
)
f
.
write
(
b'x'
)
f
.
close
()
with
open
(
'cache'
,
'wb'
)
as
f
:
f
.
write
(
ZEO
.
cache
.
magic
+
b'
\
0
'
*
8
+
b'f'
+
struct
.
pack
(
">I"
,
(
1
<<
32
)
-
12
)
)
f
.
seek
((
1
<<
32
)
-
1
)
f
.
write
(
b'x'
)
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
.
close
()
cache
=
ZEO
.
cache
.
ClientCache
(
'cache'
,
size
=
1
<<
32
)
cache
.
close
()
f
=
open
(
'cache'
,
'rb'
)
f
.
seek
(
12
)
self
.
assertEquals
(
f
.
read
(
1
),
b'f'
)
self
.
assertEquals
(
struct
.
unpack
(
">I"
,
f
.
read
(
4
))[
0
],
ZEO
.
cache
.
max_block_size
)
f
.
close
()
with
open
(
'cache'
,
'rb'
)
as
f
:
f
.
seek
(
12
)
self
.
assertEquals
(
f
.
read
(
1
),
b'f'
)
self
.
assertEquals
(
struct
.
unpack
(
">I"
,
f
.
read
(
4
))[
0
],
ZEO
.
cache
.
max_block_size
)
if
not
sys
.
platform
.
startswith
(
'linux'
):
# 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
writes records to a cache file repeatedly.
>>> import os, random, sys, time
>>> with open('t', 'w') as f
ile
:
... _ = f
ile
.write('''
>>> with open('t', 'w') as f:
... _ = f.write('''
... import os, random, sys, time
... try:
... import thread
...
...
@@ -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.
>>> with open('cache', 'w') as f
ile
:
... _ = f
ile
.write('x'*100)
>>> with open('cache', 'w') as f:
... _ = f.write('x'*100)
>>> import logging, sys
>>> handler = logging.StreamHandler(sys.stdout)
>>> logging.getLogger().addHandler(handler)
...
...
@@ -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.close()
>>>
f = open('cache')
>>>
_ = f.seek(0, 2)
>>>
print(f.tell())
>>>
with open('cache') as f:
...
_ = f.seek(0, 2)
...
print(f.tell())
1000
>>> f.close()
>>> with open('cache', 'w') as f
ile
:
... _ = f
ile
.write('x'*200)
>>> with open('cache', 'w') as f:
... _ = f.write('x'*200)
>>> cache = ZEO.cache.ClientCache('cache', 1000) # doctest: +ELLIPSIS
Removing bad cache file: 'cache' (prev bad exists).
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.
>>> cache.store(p64(1), p64(1), None, b'data')
>>> cache.close()
>>>
f = open('cache')
>>>
_ = f.seek(0, 2)
>>>
print(f.tell())
>>>
with open('cache') as f:
...
_ = f.seek(0, 2)
...
print(f.tell())
1000
>>> f.close()
>>>
f = open('cache.bad')
>>>
_ = f.seek(0, 2)
>>>
print(f.tell())
>>>
with open('cache.bad') as f:
...
_ = f.seek(0, 2)
...
print(f.tell())
100
>>> f.close()
>>> logging.getLogger().removeHandler(handler)
>>> 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