Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def point(point):
assert isinstance(point, Point)
return point
@pytest.mark.parametrize('alien', [Alien()])
@scenario('test.feature', 'Complex', example_converters=dict(point=Point.parse))
def test_complex(alien):
pass
"""
)
)
result = testdir.inline_run("-vvl")
report = result.matchreport("test_complex[point0-alien0]", when="call")
assert execnet.gateway_base.dumps(report.item)
assert execnet.gateway_base.dumps(report.scenario)
def serialize_warning_message(warning_message):
if isinstance(warning_message.message, Warning):
message_module = type(warning_message.message).__module__
message_class_name = type(warning_message.message).__name__
message_str = str(warning_message.message)
# check now if we can serialize the warning arguments (#349)
# if not, we will just use the exception message on the master node
try:
dumps(warning_message.message.args)
except DumpError:
message_args = None
else:
message_args = warning_message.message.args
else:
message_str = warning_message.message
message_module = None
message_class_name = None
message_args = None
if warning_message.category:
category_module = warning_message.category.__module__
category_class_name = warning_message.category.__name__
else:
category_module = None
category_class_name = None
"message_str": message_str,
"message_module": message_module,
"message_class_name": message_class_name,
"message_args": message_args,
"category_module": category_module,
"category_class_name": category_class_name,
}
# access private _WARNING_DETAILS because the attributes vary between Python versions
for attr_name in warning_message._WARNING_DETAILS:
if attr_name in ("message", "category"):
continue
attr = getattr(warning_message, attr_name)
# Check if we can serialize the warning detail, marking `None` otherwise
# Note that we need to define the attr (even as `None`) to allow deserializing
try:
dumps(attr)
except DumpError:
result[attr_name] = repr(attr)
else:
result[attr_name] = attr
return result
assert isinstance(point, Point)
return point
@pytest.mark.parametrize('alien', [Alien()])
@scenario('test.feature', 'Complex', example_converters=dict(point=Point.parse))
def test_complex(alien):
pass
"""
)
)
result = testdir.inline_run("-vvl")
report = result.matchreport("test_complex[point0-alien0]", when="call")
assert execnet.gateway_base.dumps(report.item)
assert execnet.gateway_base.dumps(report.scenario)
def store_block(self, type, args, parent=None):
# we choose the simplest data structure to create a block for a states_fs
# each block references a parent block (or None if it's the
# genesis block) and a timestamp.
data = [type, parent, time.time()] + list(args)
serialized = dumps(data)
cid = hashlib.sha256(serialized).hexdigest()
path = os.path.join(self._basedir, cid)
with open(path, "wb") as f:
f.write(serialized)
return Block(cid, data, bs=self)