Skip to content

Commit

Permalink
#3 Reorder functions in tests for utils module
Browse files Browse the repository at this point in the history
  • Loading branch information
astropenguin committed Aug 22, 2021
1 parent 00cf2d4 commit eca63bb
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

# submodules
from xarray_accessors.utils import (
get_nested_attr,
set_nested_attr,
del_nested_attr,
get_nested_attr,
has_nested_attr,
set_nested_attr,
)


Expand All @@ -23,19 +23,6 @@ class Data:


# test functions
def test_get_nested_attr() -> None:
names = ("a", "b", "c")
expected = data.a.b.c # type: ignore
assert get_nested_attr(data, names) == expected


def test_set_nested_attr() -> None:
names = ("a", "b", "d")
expected = "data"
set_nested_attr(data, names, expected)
assert data.a.b.d == expected # type: ignore


def test_del_nested_attr() -> None:
names = ("a", "b", "e")
data.a.b.e = "data" # type: ignore
Expand All @@ -45,6 +32,19 @@ def test_del_nested_attr() -> None:
data.a.b.e # type: ignore


def test_get_nested_attr() -> None:
names = ("a", "b", "c")
expected = data.a.b.c # type: ignore
assert get_nested_attr(data, names) == expected


def test_has_nested_attr() -> None:
names = ("a", "b", "c")
assert has_nested_attr(data, names)


def test_set_nested_attr() -> None:
names = ("a", "b", "d")
expected = "data"
set_nested_attr(data, names, expected)
assert data.a.b.d == expected # type: ignore

0 comments on commit eca63bb

Please sign in to comment.