diff --git a/tests/fixtures/responses.py b/tests/fixtures/responses.py index b31f7dd..9c38d83 100644 --- a/tests/fixtures/responses.py +++ b/tests/fixtures/responses.py @@ -26,7 +26,7 @@ import json from json import JSONDecodeError from os import environ from pathlib import Path -from typing import Any, ContextManager, Dict, Iterator, Union, Type +from typing import Any, ContextManager, Dict, Iterator, Optional, Union, Type import importlib_resources as resources import pytest @@ -35,6 +35,8 @@ from requests import Session, Response from requests.sessions import Request from requests_mock import Mocker +from fimfarchive.utils import JayWalker + __all__ = ( 'responses', @@ -58,6 +60,7 @@ class Recorder(ContextManager['Recorder']): """ self.original = Session.send self.responses: Dict = dict() + self.walker: Optional[JayWalker] self.path = path def __iter__(self) -> Iterator[Dict[str, Any]]: @@ -128,6 +131,10 @@ class Recorder(ContextManager['Recorder']): Session.send = self.original # type: ignore data = {NAMESPACE: list(self)} + walker = self.walker + + if walker is not None: + walker.walk(data) with open(self.path, 'wt') as fobj: json.dump(data, fobj, sort_keys=True, indent=4)