Skip to content

Commit

Permalink
renaming files, yet to deal with ambr snapshot extension and curly br…
Browse files Browse the repository at this point in the history
…ackets
  • Loading branch information
atharva-2001 committed Oct 11, 2023
1 parent e500a63 commit c093b3c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def pytest_configure(config):
from tardis.simulation import Simulation

from syrupy.data import SnapshotCollection
from syrupy.extensions.single_file import SingleFileSnapshotExtension
from syrupy.types import SerializableData
from syrupy.extensions.single_file import SingleFileSnapshotExtension, WriteMode
from syrupy.types import SerializableData, SnapshotIndex
from syrupy.location import PyTestLocation
from typing import Any, List, Tuple

Expand Down Expand Up @@ -245,8 +245,21 @@ def simulation_verysimple(config_verysimple, atomic_dataset):
# fixtures and plugins for syrupy/regression data testing
# -------------------------------------------------------------------------

class SingleFileSanitizedNames(SingleFileSnapshotExtension):
_write_mode = WriteMode.TEXT

class NumpySnapshotExtenstion(SingleFileSnapshotExtension):
@classmethod
def get_snapshot_name(
cls, *, test_location: "PyTestLocation", index: "SnapshotIndex"
) -> str:
original_name = SingleFileSnapshotExtension.get_snapshot_name(
test_location=test_location, index=index
)
name = original_name.replace("[", "__").replace("]", "__")
return f"{name}"


class NumpySnapshotExtenstion(SingleFileSanitizedNames):
_file_extension = "npy"

def matches(self, *, serialized_data, snapshot_data):
Expand Down Expand Up @@ -291,8 +304,8 @@ def serialize(self, data: SerializableData, **kwargs: Any) -> str:
return data


class PandasSnapshotExtenstion(SingleFileSnapshotExtension):
_file_extension = "hdf"
class PandasSnapshotExtenstion(SingleFileSanitizedNames):
_file_extension = "h5"

def matches(self, *, serialized_data, snapshot_data):
try:
Expand Down

0 comments on commit c093b3c

Please sign in to comment.