Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
yfukai committed Dec 30, 2024
1 parent 87c8689 commit 8e325cb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from laptrack import LapTrack
from laptrack import laptrack
from laptrack._tracking import _ALIAS_FIELDS
from laptrack.data_conversion import convert_tree_to_dataframe

warnings.simplefilter("ignore", FutureWarning)
Expand Down Expand Up @@ -426,6 +427,29 @@ def test_no_connected_node(tracker_class) -> None:
assert (frame, index) in track_tree.nodes()


def test_alias_and_deprecation_warning():
# Check that the alias works and issues a warning
for old_name, new_name in _ALIAS_FIELDS.items():
with warnings.catch_warnings(record=True) as w:
if "metric" in old_name:
test_value = "euclidean"
else:
test_value = 20**2
warnings.simplefilter("always") # Ensure all warnings are captured
lt = LapTrack(**{old_name: test_value})
assert (
getattr(lt, new_name) == test_value
) # Validate the correct field is populated

# Check if a DeprecationWarning was raised
assert len(w) == 1 # Only one warning should be present
assert issubclass(w[0].category, DeprecationWarning)
assert (
f"Use of `{old_name}` is deprecated, use `{new_name}` instead."
== str(w[0].message)
)


# # %%
# filename_suffix, params = FILENAME_SUFFIX_PARAMS[-1]
# # params['splitting_cutoff']=False
Expand Down

0 comments on commit 8e325cb

Please sign in to comment.