Rename hooks: to/from_serializable
This commit is contained in:
@@ -376,7 +376,7 @@ def pytest_runtest_logreport(report):
|
||||
|
||||
|
||||
@hookspec(firstresult=True)
|
||||
def pytest_report_serialize(config, report):
|
||||
def pytest_report_to_serializable(config, report):
|
||||
"""
|
||||
.. warning::
|
||||
This hook is experimental and subject to change between pytest releases, even
|
||||
@@ -394,7 +394,7 @@ def pytest_report_serialize(config, report):
|
||||
|
||||
|
||||
@hookspec(firstresult=True)
|
||||
def pytest_report_unserialize(config, data):
|
||||
def pytest_report_from_serializable(config, data):
|
||||
"""
|
||||
.. warning::
|
||||
This hook is experimental and subject to change between pytest releases, even
|
||||
@@ -406,7 +406,7 @@ def pytest_report_unserialize(config, data):
|
||||
|
||||
In the future it might become part of the public hook API.
|
||||
|
||||
Restores a report object previously serialized with pytest_report_serialize().
|
||||
Restores a report object previously serialized with pytest_report_to_serializable().
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -409,14 +409,14 @@ class CollectErrorRepr(TerminalRepr):
|
||||
out.line(self.longrepr, red=True)
|
||||
|
||||
|
||||
def pytest_report_serialize(report):
|
||||
def pytest_report_to_serializable(report):
|
||||
if isinstance(report, (TestReport, CollectReport)):
|
||||
data = report._to_json()
|
||||
data["_report_type"] = report.__class__.__name__
|
||||
return data
|
||||
|
||||
|
||||
def pytest_report_unserialize(data):
|
||||
def pytest_report_from_serializable(data):
|
||||
if "_report_type" in data:
|
||||
if data["_report_type"] == "TestReport":
|
||||
return TestReport._from_json(data)
|
||||
|
||||
Reference in New Issue
Block a user