Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
refactor: considered ssort, but blocked by bwhmather/ssort#70
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Sep 25, 2022
1 parent 7371065 commit b77f4ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pytest_cache_assert/_check_assert/assert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
class AssertConfig:
"""User configuration data structure."""

class Config:
arbitrary_types_allowed = True
frozen = True

always_write: bool = False
"""Always write to the cached file so that diffs can be examined in the user's VCS."""

Expand Down Expand Up @@ -48,10 +52,6 @@ def panda_to_json(df: pd.DataFrame) -> List[Dict]:
validator: ValidatorType = Field(default_factory=DictDiffValidator)
"""Custom validator for identifying and summarizing the deviations from the cache."""

class Config:
arbitrary_types_allowed = True
frozen = True

def __post_init_post_parse__(self) -> None:
"""Register the configuration object."""
if self.always_write:
Expand Down
12 changes: 6 additions & 6 deletions pytest_cache_assert/_check_assert/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def get_lookup(self) -> Dict[Any, List[T_CONVERTER]]:
_CONVERTERS = _Converters()


def _generic_memory_address_serializer(obj: Any) -> Any:
if _RE_MEMORY_ADDRESS.search(str(obj)):
return replace_memory_address(obj)
raise Unconvertable("Not a match for 'replace_memory_address'")


class _CacheAssertSerializer(JSONEncoder):
"""Expand serializable types beyond default encoder.
Expand Down Expand Up @@ -92,12 +98,6 @@ def default(self, obj: Any) -> Any:
raise Unconvertable(f'Failed to encode `{obj}` ({type(obj)}) with {_CONVERTERS.get_lookup()}')


def _generic_memory_address_serializer(obj: Any) -> Any:
if _RE_MEMORY_ADDRESS.search(str(obj)):
return replace_memory_address(obj)
raise Unconvertable("Not a match for 'replace_memory_address'")


_CONVERTERS.register([Callable], _generic_memory_address_serializer)


Expand Down
8 changes: 4 additions & 4 deletions pytest_cache_assert/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
class TestMetadata(BaseModel):
"""Test MetaData."""

test_file: str
test_name: str
func_args: Union[Dict, Iterable] # type: ignore[type-arg]

class Config:
arbitrary_types_allowed = True
frozen = True

test_file: str
test_name: str
func_args: Union[Dict, Iterable] # type: ignore[type-arg]

@classmethod
@beartype
def from_pytest(cls, request: FixtureRequest, rel_test_file: Path) -> TestMetadata:
Expand Down

0 comments on commit b77f4ee

Please sign in to comment.