From a8d8da25fdd56958320f5dccae44548463c6c550 Mon Sep 17 00:00:00 2001 From: protolambda Date: Mon, 6 May 2019 15:40:18 +0200 Subject: [PATCH] fix wording and improve encoding logic --- test_libs/pyspec/tests/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test_libs/pyspec/tests/utils.py b/test_libs/pyspec/tests/utils.py index f13eede65..b19d4df59 100644 --- a/test_libs/pyspec/tests/utils.py +++ b/test_libs/pyspec/tests/utils.py @@ -3,7 +3,7 @@ from eth2spec.debug.encode import encode def spectest(description: str = None): def runner(fn): - # this wraps the function, to hide that the function actually yielding data. + # this wraps the function, to hide that the function actually is yielding data, instead of returning once. def entry(*args, **kw): # check generator mode, may be None/else. # "pop" removes it, so it is not passed to the inner function. @@ -25,9 +25,12 @@ def spectest(description: str = None): (key, value, typ) = data out[key] = encode(value, typ) else: - # Otherwise, just put the raw value. + # Otherwise, try to infer the type, but keep it as-is if it's not a SSZ container. (key, value) = data - out[key] = value + if hasattr(value.__class__, 'fields'): + out[key] = encode(value, value.__class__) + else: + out[key] = value return out else: # just complete the function, ignore all yielded data, we are not using it