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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
d820dcea
Commit
d820dcea
authored
Jul 11, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More comprehensive testing of clear_socket using mock.patch
parent
f34a9b06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
src/ZEO/runzeo.py
src/ZEO/runzeo.py
+0
-1
src/ZEO/tests/testZEOServer.py
src/ZEO/tests/testZEOServer.py
+35
-8
No files found.
src/ZEO/runzeo.py
View file @
d820dcea
...
...
@@ -196,7 +196,6 @@ class ZEOServer(object):
os
.
unlink
(
self
.
options
.
address
)
except
os
.
error
:
pass
return
True
def
open_storages
(
self
):
self
.
storages
=
{}
...
...
src/ZEO/tests/testZEOServer.py
View file @
d820dcea
import
unittest
import
mock
import
os
from
ZEO._compat
import
PY3
from
ZEO.runzeo
import
ZEOServer
...
...
@@ -134,19 +138,42 @@ class CloseServerTests(unittest.TestCase):
self
.
assertEqual
(
hasattr
(
zeo
,
"server"
),
True
)
self
.
assertEqual
(
zeo
.
server
,
None
)
@
mock
.
patch
(
'os.unlink'
)
class
TestZEOServerSocket
(
unittest
.
TestCase
):
def
test_clear_with_native_str
(
self
):
def
_unlinked
(
self
,
unlink
,
options
):
server
=
ZEOServer
(
options
)
server
.
clear_socket
()
unlink
.
assert_called_once
()
def
_not_unlinked
(
self
,
unlink
,
options
):
server
=
ZEOServer
(
options
)
server
.
clear_socket
()
unlink
.
assert_not_called
()
def
test_clear_with_native_str
(
self
,
unlink
):
class
Options
(
object
):
address
=
"a str that does not exist"
self
.
_unlinked
(
unlink
,
Options
)
server
=
ZEOServer
(
Options
())
self
.
assertTrue
(
server
.
clear_socket
())
def
test_clear_with_unicode_str
(
self
):
def
test_clear_with_unicode_str
(
self
,
unlink
):
class
Options
(
object
):
address
=
u"a str that does not exist"
self
.
_unlinked
(
unlink
,
Options
)
server
=
ZEOServer
(
Options
())
self
.
assertTrue
(
server
.
clear_socket
())
def
test_clear_with_bytes
(
self
,
unlink
):
class
Options
(
object
):
address
=
b'a byte str that does not exist'
if
PY3
:
# bytes are not a string type under Py3
assertion
=
self
.
_not_unlinked
else
:
assertion
=
self
.
_unlinked
assertion
(
unlink
,
Options
)
def
test_clear_with_tuple
(
self
,
unlink
):
class
Options
(
object
):
address
=
(
'abc'
,
1
)
self
.
_not_unlinked
(
unlink
,
Options
)
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