Skip to content

Commit

Permalink
test_deprecations.py
Browse files Browse the repository at this point in the history
  • Loading branch information
VeckoTheGecko committed Sep 20, 2024
1 parent 02906d8 commit 35bb37c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pytest

from tests.utils import create_fieldset_unit_mesh

fieldset = create_fieldset_unit_mesh()
field = fieldset.U

private_field_attrs = [
"_dataFiles",
"_loaded_time_indices",
"_creation_log",
"_data_chunks",
"_c_data_chunks",
"_chunk_set",
]

private_fieldset_attrs = [
"_completed",
]


@pytest.mark.parametrize("private_attribute", private_field_attrs)
def test_private_attribute_field(private_attribute):
assert private_attribute.startswith("_")
attribute = private_attribute.lstrip("_")

with pytest.raises(DeprecationWarning):
assert hasattr(field, attribute)
assert hasattr(field, private_attribute)
assert getattr(field, attribute) == getattr(field, private_attribute)

Check warning on line 30 in tests/test_deprecations.py

View check run for this annotation

Codecov / codecov/patch

tests/test_deprecations.py#L29-L30

Added lines #L29 - L30 were not covered by tests


@pytest.mark.parametrize("private_attribute", private_fieldset_attrs)
def test_private_attribute_fieldset(private_attribute):
assert private_attribute.startswith("_")
attribute = private_attribute.lstrip("_")

with pytest.raises(DeprecationWarning):
assert hasattr(fieldset, attribute)
assert hasattr(fieldset, private_attribute)
assert getattr(fieldset, attribute) == getattr(fieldset, private_attribute)

Check warning on line 41 in tests/test_deprecations.py

View check run for this annotation

Codecov / codecov/patch

tests/test_deprecations.py#L40-L41

Added lines #L40 - L41 were not covered by tests

0 comments on commit 35bb37c

Please sign in to comment.