Skip to content

Commit

Permalink
fix(tests): resolves issue with mypy (read: me) being stupid
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Jun 26, 2023
1 parent dfabc63 commit 6956665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Empty file added tests/__init__.py
Empty file.
10 changes: 5 additions & 5 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
from niapi.utils import camel_case, case_insensitive_string_compare, check_email, dataclass_as_dict_shallow, slugify


@given(st.emails()) # type: ignore[misc]
@given(st.emails())
def test_check_email(email: str) -> None:
assert check_email(email) == email.lower()


@given(st.text(alphabet=string.ascii_letters + string.digits + string.whitespace + "-")) # type: ignore[misc]
@given(st.text(alphabet=string.ascii_letters + string.digits + string.whitespace + "-"))
def test_slugify(value: str) -> None:
if all(c in string.whitespace or c == "-" for c in value):
assert slugify(value) == re.sub(r"[-\s]+", "-", value.lower()).strip("-_")
else:
assert slugify(value)


@given(st.text(st.characters(blacklist_characters="_"))) # type: ignore[misc]
@given(st.text(st.characters(blacklist_characters="_")))
def test_camel_case(string: str) -> None:
assert camel_case(string) == "".join(
word if index == 0 else word.capitalize() for index, word in enumerate(string.split("_"))
)


@given(st.text(), st.text()) # type: ignore[misc]
@given(st.text(), st.text())
def test_case_insensitive_string_compare(a: str, b: str) -> None:
assert case_insensitive_string_compare(a, b) == (a.strip().lower() == b.strip().lower())


@given(st.text(min_size=1), st.integers()) # type: ignore[misc]
@given(st.text(min_size=1), st.integers())
def test_dataclass_as_dict_shallow(name: str, value: int) -> None:
@dataclass
class TestClass:
Expand Down

0 comments on commit 6956665

Please sign in to comment.