Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
gevent
Commits
9ae48126
Commit
9ae48126
authored
Apr 17, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Plain Diff
Merge master-testfix
parents
b6bc1bf6
e1dd49f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
greentest/test__socket_dns.py
greentest/test__socket_dns.py
+27
-4
greentest/test_ares_timeout.py
greentest/test_ares_timeout.py
+4
-3
No files found.
greentest/test__socket_dns.py
View file @
9ae48126
...
...
@@ -86,15 +86,32 @@ def compare_relaxed(a, b):
>>> compare_relaxed('2a00:1450:4016:800::1013', '2a00:1450:4008:c01::93')
True
>>> compare_relaxed('2001:470::e852:4a38:9d7f:0', '2001:470:6d00:1c:1::d00')
True
>>> compare_relaxed('2001:470:4147:4943:6161:6161:2e74:6573', '2001:470::')
True
>>> compare_relaxed('2607:f8b0:6708:24af:1fd:700:60d4:4af', '2607:f8b0:2d00::f000:0')
True
>>> compare_relaxed('a.surfly.com', 'b.surfly.com')
True
>>> compare_relaxed('a.surfly.com', 'a.gevent.org')
False
"""
if
a
.
count
(
':'
)
==
5
and
b
.
count
(
':'
)
==
5
:
# IPv6 address from different requests might be different
return
True
# IPv6 address from different requests might be different
a_segments
=
a
.
count
(
':'
)
b_segments
=
b
.
count
(
':'
)
if
a_segments
and
b_segments
:
if
a_segments
==
b_segments
and
a_segments
in
(
4
,
5
,
6
,
7
):
return
True
if
a
.
rstrip
(
':'
).
startswith
(
b
.
rstrip
(
':'
))
or
b
.
rstrip
(
':'
).
startswith
(
a
.
rstrip
(
':'
)):
return
True
if
a_segments
>=
2
and
b_segments
>=
2
and
a
.
split
(
':'
)[:
2
]
==
b
.
split
(
':'
)[:
2
]:
return
True
return
a
.
split
(
'.'
,
1
)[
-
1
]
==
b
.
split
(
'.'
,
1
)[
-
1
]
...
...
@@ -223,7 +240,13 @@ class TestCase(greentest.TestCase):
return
if relaxed_is_equal(gevent_result, real_result):
return
raise AssertionError('
%
r
!=
%
r
\
n
%
s
' % (gevent_result, real_result, format_call(func, args)))
# From 2.7 on, assertEqual does a better job highlighting the results than we would
# because it calls assertSequenceEqual, which highlights the exact
# difference in the tuple
msg = format_call(func, args)
self.assertEqual((msg,gevent_result), (msg,real_result))
class TestTypeError(TestCase):
...
...
greentest/test_ares_timeout.py
View file @
9ae48126
...
...
@@ -10,13 +10,14 @@ except ImportError as ex:
from
gevent
import
socket
print
(
gevent
.
__file__
)
address
=
(
'
127.0.0.10'
,
53
)
address
=
(
'
'
,
71
53
)
listener
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
try
:
listener
.
bind
(
address
)
except
socket
.
error
as
ex
:
if
ex
.
errno
in
(
errno
.
EPERM
,
errno
.
EADDRNOTAVAIL
)
or
'permission denied'
in
str
(
ex
).
lower
():
sys
.
stderr
.
write
(
'This test binds on port
53 and thus must be run as root
.
\
n
'
)
sys
.
stderr
.
write
(
'This test binds on port
a port that was already in use or not allowed
.
\
n
'
)
sys
.
exit
(
0
)
raise
...
...
@@ -27,7 +28,7 @@ def reader():
gevent
.
spawn
(
reader
)
r
=
gevent
.
get_hub
().
resolver
=
Resolver
(
servers
=
[
'127.0.0.1
0'
],
timeout
=
0.001
,
tries
=
1
)
r
=
gevent
.
get_hub
().
resolver
=
Resolver
(
servers
=
[
'127.0.0.1
'
],
timeout
=
0.001
,
tries
=
1
,
udp_port
=
address
[
-
1
]
)
try
:
result
=
r
.
gethostbyname
(
'www.google.com'
)
except
socket
.
gaierror
as
ex
:
...
...
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