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
1910b1d6
Commit
1910b1d6
authored
Jan 24, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use assertTimeWithinRange for better control on PyPy/Windows.
parent
23f32416
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
21 deletions
+23
-21
src/greentest/greentest/testcase.py
src/greentest/greentest/testcase.py
+17
-18
src/greentest/known_failures.py
src/greentest/known_failures.py
+3
-1
src/greentest/lock_tests.py
src/greentest/lock_tests.py
+3
-2
No files found.
src/greentest/greentest/testcase.py
View file @
1910b1d6
...
...
@@ -34,6 +34,22 @@ from greentest import flaky
from
greentest.patched_tests_setup
import
get_switch_expected
class
TimeAssertMixin
(
object
):
def
assertTimeoutAlmostEqual
(
self
,
first
,
second
,
places
=
None
,
msg
=
None
,
delta
=
None
):
try
:
self
.
assertAlmostEqual
(
first
,
second
,
places
=
places
,
msg
=
msg
,
delta
=
delta
)
except
AssertionError
:
flaky
.
reraiseFlakyTestTimeout
()
if
sysinfo
.
EXPECT_POOR_TIMER_RESOLUTION
:
# pylint:disable=unused-argument
def
assertTimeWithinRange
(
self
,
delay
,
min_time
,
max_time
):
return
else
:
def
assertTimeWithinRange
(
self
,
time_taken
,
min_time
,
max_time
):
self
.
assertLessEqual
(
time_taken
,
max_time
)
self
.
assertGreaterEqual
(
time_taken
,
min_time
)
...
...
@@ -101,7 +117,7 @@ class TestCaseMetaClass(type):
def
_noop
():
return
class
TestCase
(
TestCaseMetaClass
(
"NewBase"
,
(
BaseTestCase
,),
{})):
class
TestCase
(
TestCaseMetaClass
(
"NewBase"
,
(
TimeAssertMixin
,
BaseTestCase
,),
{})):
__timeout__
=
params
.
LOCAL_TIMEOUT
if
not
sysinfo
.
RUNNING_ON_CI
else
params
.
CI_TIMEOUT
switch_expected
=
'default'
...
...
@@ -225,23 +241,6 @@ class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})):
self
.
assertIsInstance
(
econtext
,
where_type
)
return
error
def
assertTimeoutAlmostEqual
(
self
,
first
,
second
,
places
=
None
,
msg
=
None
,
delta
=
None
):
try
:
self
.
assertAlmostEqual
(
first
,
second
,
places
=
places
,
msg
=
msg
,
delta
=
delta
)
except
AssertionError
:
flaky
.
reraiseFlakyTestTimeout
()
if
sysinfo
.
EXPECT_POOR_TIMER_RESOLUTION
:
# pylint:disable=unused-argument
def
assertTimeWithinRange
(
self
,
delay
,
min_time
,
max_time
):
return
else
:
def
assertTimeWithinRange
(
self
,
time_taken
,
min_time
,
max_time
):
self
.
assertLessEqual
(
time_taken
,
max_time
)
self
.
assertGreaterEqual
(
time_taken
,
min_time
)
def
assertMonkeyPatchedFuncSignatures
(
self
,
mod_name
,
func_names
=
(),
exclude
=
()):
# We use inspect.getargspec because it's the only thing available
# in Python 2.7, but it is deprecated
...
...
src/greentest/known_failures.py
View file @
1910b1d6
...
...
@@ -74,7 +74,9 @@ if sys.platform == 'win32':
# This one sometimes seems to just stop right after
# patching is done. It passes on a local win 10 vm, and the main
# test_threading_2.py does as well.
# https://ci.appveyor.com/project/denik/gevent/build/1.0.1275/job/3uxm8y463v3p6d87#L1182
# Based on the printouts we added, it appears to not even
# finish importing:
# https://ci.appveyor.com/project/denik/gevent/build/1.0.1277/job/tpvhesij5gldjxqw#L1190
'FLAKY test_threading.py'
,
]
...
...
src/greentest/lock_tests.py
View file @
1910b1d6
...
...
@@ -15,6 +15,7 @@ try:
except
ImportError
:
from
test
import
test_support
as
support
from
greentest.testcase
import
TimeAssertMixin
def
_wait
():
# A crude wait/yield function not relying on synchronization primitives.
...
...
@@ -59,7 +60,7 @@ class Bunch(object):
self
.
_can_exit
=
True
class
BaseTestCase
(
unittest
.
TestCase
):
class
BaseTestCase
(
TimeAssertMixin
,
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_threads
=
support
.
threading_setup
()
...
...
@@ -306,7 +307,7 @@ class EventTests(BaseTestCase):
self
.
assertEqual
(
results1
,
[
False
]
*
N
)
for
r
,
dt
in
results2
:
self
.
assertFalse
(
r
)
self
.
assertT
rue
(
dt
>=
0.19
,
dt
)
# XXX: libuv sometimes produces 0.19958
self
.
assertT
imeWithinRange
(
dt
,
0.18
,
10
)
# The event is set
results1
=
[]
results2
=
[]
...
...
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