mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
Merge branch '3564.eliot-log-testing-python-3' into 3566.web-tests-python-3-part-2
This commit is contained in:
commit
a8732a3c70
0
newsfragments/3564.minor
Normal file
0
newsfragments/3564.minor
Normal file
4
setup.py
4
setup.py
@ -111,7 +111,9 @@ install_requires = [
|
|||||||
|
|
||||||
# Eliot is contemplating dropping Python 2 support. Stick to a version we
|
# Eliot is contemplating dropping Python 2 support. Stick to a version we
|
||||||
# know works on Python 2.7.
|
# know works on Python 2.7.
|
||||||
"eliot ~= 1.7",
|
"eliot ~= 1.7 ; python_version < '3.0'",
|
||||||
|
# On Python 3, we want a new enough version to support custom JSON encoders.
|
||||||
|
"eliot >= 1.13.0 ; python_version > '3.0'",
|
||||||
|
|
||||||
# Pyrsistent 0.17.0 (which we use by way of Eliot) has dropped
|
# Pyrsistent 0.17.0 (which we use by way of Eliot) has dropped
|
||||||
# Python 2 entirely; stick to the version known to work for us.
|
# Python 2 entirely; stick to the version known to work for us.
|
||||||
|
@ -31,6 +31,9 @@ from twisted.internet.defer import (
|
|||||||
maybeDeferred,
|
maybeDeferred,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from ..util.jsonbytes import BytesJSONEncoder
|
||||||
|
|
||||||
|
|
||||||
_NAME = Field.for_types(
|
_NAME = Field.for_types(
|
||||||
u"name",
|
u"name",
|
||||||
[str],
|
[str],
|
||||||
@ -61,6 +64,14 @@ def eliot_logged_test(f):
|
|||||||
class storage(object):
|
class storage(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# On Python 3, we want to use our custom JSON encoder when validating
|
||||||
|
# messages can be encoded to JSON:
|
||||||
|
if PY3:
|
||||||
|
capture = lambda f : capture_logging(None, encoder_=BytesJSONEncoder)(f)
|
||||||
|
else:
|
||||||
|
capture = lambda f : capture_logging(None)(f)
|
||||||
|
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def run_and_republish(self, *a, **kw):
|
def run_and_republish(self, *a, **kw):
|
||||||
# Unfortunately the only way to get at the global/default logger...
|
# Unfortunately the only way to get at the global/default logger...
|
||||||
@ -85,7 +96,7 @@ def eliot_logged_test(f):
|
|||||||
# can finish the test's action.
|
# can finish the test's action.
|
||||||
storage.action.finish()
|
storage.action.finish()
|
||||||
|
|
||||||
@capture_logging(None)
|
@capture
|
||||||
def run(self, logger):
|
def run(self, logger):
|
||||||
# Record the MemoryLogger for later message extraction.
|
# Record the MemoryLogger for later message extraction.
|
||||||
storage.logger = logger
|
storage.logger = logger
|
||||||
@ -165,9 +176,6 @@ class EliotLoggedRunTest(object):
|
|||||||
|
|
||||||
@eliot_logged_test
|
@eliot_logged_test
|
||||||
def run(self, result=None):
|
def run(self, result=None):
|
||||||
# Workaround for https://github.com/itamarst/eliot/issues/456
|
|
||||||
if PY3:
|
|
||||||
self.case.eliot_logger._validate_message = lambda *args, **kwargs: None
|
|
||||||
return self._run_tests_with_factory(
|
return self._run_tests_with_factory(
|
||||||
self.case,
|
self.case,
|
||||||
self.handlers,
|
self.handlers,
|
||||||
|
Loading…
Reference in New Issue
Block a user