Skip to content

Commit

Permalink
Merge pull request #28 from eredotpkfr/typing-fixes
Browse files Browse the repository at this point in the history
chore: typing fixes
  • Loading branch information
eredotpkfr authored Jan 10, 2024
2 parents a31348d + eeefd7b commit 2ff6641
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]

requires = [
'setuptools>=67.7.2',
'setuptools>=69.0.3',
'wheel'
]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3

"""
Module installation file
Module installation file.
"""

from setuptools import Extension, setup
Expand Down
10 changes: 5 additions & 5 deletions tests/cases.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python3

"""
Test cases listed in this file
Test cases listed in this file.
"""

IPV4_CASES = {
IPV4_CASES: dict[str, bool] = {
"0.0.0.0": True,
"127.0.0.1": True,
"10.0.0.0": True,
Expand Down Expand Up @@ -33,7 +33,7 @@
" ": False,
}

IPV4_CIDR_CASES = {
IPV4_CIDR_CASES: dict[str, bool] = {
"0.0.0.0/0": True,
"127.0.0.1/0": True,
"123.5.77.88/8": True,
Expand All @@ -60,7 +60,7 @@
"foo/bar": False,
}

IPV6_CASES = {
IPV6_CASES: dict[str, bool] = {
"::1": True,
"2002::": True,
"dead:beef:0:0:0:0:42:1": True,
Expand All @@ -82,7 +82,7 @@
"deag:beef:0:0:0:0:42:1": False,
}

IPV6_CIDR_CASES = {
IPV6_CIDR_CASES: dict[str, bool] = {
"::1/0": True,
"2002::/12": True,
"dead:beef:0:0:0:0:42:1/8": True,
Expand Down
28 changes: 18 additions & 10 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3

"""
Main test file, fipv module tests
Main test file, fipv module tests.
"""


Expand All @@ -14,30 +14,38 @@


class TestFipv(TestCase):
"""Main module test class"""
"""Main module test class."""

def _global_test_func(self, cases: dict, validator: Callable) -> None:
"""
Global test function, other methods uses it. Simply does
test by given cases and validator.
def _global_test_func(
self,
cases: dict[str, bool],
validator: Callable[[str], bool],
) -> None:
"""Global test function, other methods uses it.
Simply does test by given cases and validator.
Args:
cases: test cases as a dictionary
validator: any `fipv` validator function object
"""
for case, expected in cases.items():
self.assertEqual(validator(case), expected, case)

def test_ipv4(self) -> None:
"""Test for fipv.ipv4 func"""
"""Test for fipv.ipv4 func."""
self._global_test_func(IPV4_CASES, fipv.ipv4)

def test_ipv4_cidr(self) -> None:
"""Test for fipv.ipv4_cidr func"""
"""Test for fipv.ipv4_cidr func."""
self._global_test_func(IPV4_CIDR_CASES, fipv.ipv4_cidr)

def test_ipv6(self) -> None:
"""Test for fipv.ipv6 func"""
"""Test for fipv.ipv6 func."""
self._global_test_func(IPV6_CASES, fipv.ipv6)

def test_ipv6_cidr(self) -> None:
"""Test for fipv.ipv6_cidr func"""
"""Test for fipv.ipv6_cidr func."""
self._global_test_func(IPV6_CIDR_CASES, fipv.ipv6_cidr)


Expand Down

0 comments on commit 2ff6641

Please sign in to comment.