Commit bad36226 authored by Jason Madden's avatar Jason Madden

Minor cleanup of test__os

We saw a Windows crash (https://ci.appveyor.com/project/denik/gevent/builds/20295148/job/ldltku6gletkdfgl):

| C:\Python37-x64\python.exe -u -mgevent.tests.test__os
461  .
462  ----------------------------------------------------------------------
463  Ran 1 test in 1.656s
464
465  OK
466  Windows fatal exception: access violation
467
468  Thread 0x000003dc (most recent call first):
469
470  Current thread 0x000005c8 (most recent call first):
471    File "C:\Python37-x64\lib\site-packages\gevent\threadpool.py", line 261 in _worker
472
473  Thread 0x00000af8 (most recent call first):
474    File "C:\Python37-x64\lib\site-packages\gevent\_threading.py", line 84 in wait
475    File "C:\Python37-x64\lib\site-packages\gevent\_threading.py", line 166 in get
476    File "C:\Python37-x64\lib\site-packages\gevent\threadpool.py", line 270 in _worker
477
478  Thread 0x00000424 (most recent call first):
479    File "C:\Python37-x64\lib\site-packages\gevent\_threading.py", line 84 in wait
480    File "C:\Python37-x64\lib\site-packages\gevent\_threading.py", line 166 in get
481    File "C:\Python37-x64\lib\site-packages\gevent\threadpool.py", line 270 in _worker
482
483  Thread 0x000003dc (most recent call first):
484    File "C:\Python37-x64\lib\weakref.py", line 356 in remove
485
486! C:\Python37-x64\python.exe -u -mgevent.tests.test__os [code 3221225477] [took 1.7s]

I confirmed that the one test we run there doesn't create an
IdentRegistry. Instead, the WeakKeyDictionary that's being created
comes from either zope.interface (tracking dependents) or
concurrent.futures (tracking spawned threads).
parent 8bd70641
......@@ -68,6 +68,7 @@ from .skipping import skipOnPyPy
from .skipping import skipOnPyPyOnCI
from .skipping import skipOnPyPy3
from .skipping import skipIf
from .skipping import skipUnless
from .skipping import skipOnLibev
from .skipping import skipOnLibuv
from .skipping import skipOnLibuvOnWin
......
......@@ -92,6 +92,7 @@ if sysinfo.PYPY:
skipUnderCoverage = unittest.skip if sysinfo.RUN_COVERAGE else _do_not_skip
skipIf = unittest.skipIf
skipUnless = unittest.skipUnless
......
......@@ -36,8 +36,6 @@ DELAY = 0.1
class TestCloseSocketWhilePolling(greentest.TestCase):
def test(self):
from gevent.exceptions import ConcurrentObjectUseError
sock = socket.socket()
self._close_on_teardown(sock)
t = get_hub().loop.timer(0)
......
......@@ -6,17 +6,17 @@ from os import pipe
import gevent
from gevent import os
from gevent.testing import TestCase, main, LARGE_TIMEOUT
from gevent import Greenlet, joinall
from gevent import testing as greentest
from gevent.testing import mock
from gevent.testing import six
from gevent.testing.skipping import skipOnLibuvOnPyPyOnWin
class TestOS_tp(TestCase):
class TestOS_tp(greentest.TestCase):
__timeout__ = LARGE_TIMEOUT
__timeout__ = greentest.LARGE_TIMEOUT
def pipe(self):
return pipe()
......@@ -53,8 +53,8 @@ class TestOS_tp(TestCase):
# the pipe before the consumer starts, and would block the entire
# process. Therefore the next line would never finish.
joinall([producer, consumer])
assert bytesread[0] == nbytes
assert bytesread[0] == byteswritten[0]
self.assertEqual(bytesread[0], nbytes)
self.assertEqual(bytesread[0], byteswritten[0])
if sys.version_info[0] < 3:
......@@ -67,12 +67,15 @@ class TestOS_tp(TestCase):
self._test_if_pipe_blocks(six.builtins.memoryview)
if hasattr(os, 'make_nonblocking'):
@greentest.skipUnless(hasattr(os, 'make_nonblocking'),
"Only on POSIX")
class TestOS_nb(TestOS_tp):
class TestOS_nb(TestOS_tp):
def read(self, fd, count):
return os.nb_read(fd, count)
read = staticmethod(os.nb_read)
write = staticmethod(os.nb_write)
def write(self, fd, count):
return os.nb_write(fd, count)
def pipe(self):
r, w = super(TestOS_nb, self).pipe()
......@@ -146,11 +149,11 @@ if hasattr(os, 'make_nonblocking'):
1)
if hasattr(os, 'fork_and_watch'):
@greentest.skipUnless(hasattr(os, 'fork_and_watch'),
"Only on POSIX")
class TestForkAndWatch(greentest.TestCase):
class TestForkAndWatch(TestCase):
__timeout__ = LARGE_TIMEOUT
__timeout__ = greentest.LARGE_TIMEOUT
def test_waitpid_all(self):
# Cover this specific case.
......@@ -170,5 +173,6 @@ if hasattr(os, 'fork_and_watch'):
def test_waitpid_wrong_pos(self):
self.assertRaises(OSError, os.waitpid, 1, 0)
if __name__ == '__main__':
main()
greentest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment