pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python-validators/validators/commit/83bd6488f1ff972687b55c3ac121588da77fa02a

ymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> chore: pytest and rm bool · python-validators/validators@83bd648 · GitHub
Skip to content

Commit 83bd648

Browse files
author
inspxctelement
committed
chore: pytest and rm bool
1 parent 7614012 commit 83bd648

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/validators/ip_address.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def _check_private_ip(value: str, is_private: Optional[bool]):
3333
or re.match(r"^172\.(?:1[6-9]|2\d|3[0-1])\.", value) # private
3434
or re.match(r"^(?:22[4-9]|23[0-9]|24[0-9]|25[0-5])\.", value) # broadcast
3535
):
36-
return bool(is_private)
36+
return is_private
3737
else:
38-
return not bool(is_private)
38+
return not is_private
3939

4040

4141
@validator

tests/test_ip_address.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,6 @@ def test_returns_failed_validation_on_invalid_ipv6_cidr_address(
150150
assert isinstance(ipv6(address, cidr=cidr, strict=strict, host_bit=host_bit), ValidationError)
151151

152152

153-
@pytest.mark.parametrize(
154-
("address", "private"),
155-
[
156-
("10.1.1.1", False),
157-
("192.168.1.1", False),
158-
("169.254.1.1", False),
159-
("127.0.0.1", False),
160-
("0.0.0.0", False),
161-
],
162-
)
163-
def test_returns_failed_validation_on_private_ipv4_address(address: str, private: bool):
164-
"""Test returns failed validation on invalid ipv4 CIDR address."""
165-
assert isinstance(ipv4(address, private=private), ValidationError)
166-
167-
168153
@pytest.mark.parametrize(
169154
("address", "private"),
170155
[
@@ -176,7 +161,7 @@ def test_returns_failed_validation_on_private_ipv4_address(address: str, private
176161
],
177162
)
178163
def test_returns_valid_on_private_ipv4_address(address: str, private: bool):
179-
"""Test returns failed validation on invalid ipv4 CIDR address."""
164+
"""Test returns true on private ipv4 address."""
180165
assert ipv4(address, private=private)
181166

182167

@@ -188,8 +173,8 @@ def test_returns_valid_on_private_ipv4_address(address: str, private: bool):
188173
("7.53.12.1", True),
189174
],
190175
)
191-
def test_returns_failed_validation_on_not_private_ipv4_address(address: str, private: bool):
192-
"""Test returns failed validation on invalid ipv4 CIDR address."""
176+
def test_returns_failed_validation_on_invalid_private_ipv4_address(address: str, private: bool):
177+
"""Test returns failed validation on invalid private ipv4 address."""
193178
assert isinstance(ipv4(address, private=private), ValidationError)
194179

195180

@@ -201,6 +186,21 @@ def test_returns_failed_validation_on_not_private_ipv4_address(address: str, pri
201186
("7.53.12.1", False),
202187
],
203188
)
204-
def test_returns_valid_on_private_public_ipv4_address(address: str, private: bool):
205-
"""Test returns failed validation on invalid ipv4 CIDR address."""
189+
def test_returns_valid_on_public_ipv4_address(address: str, private: bool):
190+
"""Test returns true on valid public ipv4 address."""
206191
assert ipv4(address, private=private)
192+
193+
194+
@pytest.mark.parametrize(
195+
("address", "private"),
196+
[
197+
("10.1.1.1", False),
198+
("192.168.1.1", False),
199+
("169.254.1.1", False),
200+
("127.0.0.1", False),
201+
("0.0.0.0", False),
202+
],
203+
)
204+
def test_returns_failed_validation_on_private_ipv4_address(address: str, private: bool):
205+
"""Test returns failed validation on private ipv4 address."""
206+
assert isinstance(ipv4(address, private=private), ValidationError)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy