Skip to content

Commit

Permalink
[twisted/internet/_glibbase] Fix Typeerror in simulate for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
doadin committed Jan 12, 2022
1 parent dee676b commit b26d96c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/twisted/internet/_glibbase.py
Expand Up @@ -354,8 +354,8 @@ def simulate(self):
if self._simtag is not None:
self._source_remove(self._simtag)
self.iterate()
timeout = min(self.timeout(), 0.01)
if timeout is None:
timeout = self.timeout()
if timeout is None or timeout > 0.01:
timeout = 0.01
self._simtag = self._timeout_add(
int(timeout * 1000),
Expand Down
19 changes: 19 additions & 0 deletions src/twisted/internet/test/test_glibbase.py
Expand Up @@ -65,3 +65,22 @@ def test_ensureFailsWhenImported(self):
)
self.assertEqual(modules, {"m2": module})
self.assertEqual(e.args, ("A message.",))


class GlibReactorBaseTests(TestCase):
def test_simulate(self):
""" """
try:
from twisted.internet import gireactor as _gireactor
except ImportError:
gireactor = None
else:
gireactor = _gireactor

from twisted.trial.unittest import SkipTest

# Skip all tests if gi is unavailable:
if gireactor is None:
raise SkipTest("gi not importable")

gireactor.install().simulate()
1 change: 1 addition & 0 deletions src/twisted/newsfragments/9660.bugfix
@@ -0,0 +1 @@
twisted.internet.glibbase.simulate no longer raises TypeError with no timeout on Python 3.

0 comments on commit b26d96c

Please sign in to comment.