Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running doctest failes #417

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package/requirements.testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pycryptodome==3.20.0 \
--hash=sha256:f35d6cee81fa145333137009d9c8ba90951d7d77b67c79cbe5f03c7eb74d8fe2 \
--hash=sha256:f47888542a0633baff535a04726948e876bf1ed880fddb7c10a736fa99146ab3 \
--hash=sha256:fb3b87461fa35afa19c971b0a2b7456a7b1db7b4eba9a8424666104925b78128
pytest==8.2.2 \
--hash=sha256:c434598117762e2bd304e526244f67bf66bbd7b5d6cf22138be51ff661980343 \
--hash=sha256:de4bb8104e201939ccdc688b27a89a7be2079b22e2bd2b07f806b6ba71117977
pytest==8.3.2 \
--hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \
--hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce
tomli==2.0.1; python_version < "3.11" \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ pythonPlatform = "All"
typeCheckingMode = "strict"

[tool.pytest.ini_options]
minversion = "6.0"
pythonpath = ["src"]
testpaths = "tests"
addopts = ["--doctest-modules"]


[tool.ruff]
lint.select = [
Expand Down
28 changes: 14 additions & 14 deletions src/validators/_extremes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class AbsMax:
Inspired by https://pypi.python.org/pypi/Extremes.

Examples:
>>> from sys import maxint
>>> AbsMax > AbsMin
# Output: True
>>> AbsMax > maxint
# Output: True
>>> AbsMax > 99999999999999999
# Output: True
>>> from sys import maxsize
>>> AbsMax() > AbsMin()
True
>>> AbsMax() > maxsize
True
>>> AbsMax() > 99999999999999999
True
"""

def __ge__(self, other: Any):
Expand All @@ -33,13 +33,13 @@ class AbsMin:
Inspired by https://pypi.python.org/pypi/Extremes.

Examples:
>>> from sys import maxint
>>> AbsMin < -maxint
# Output: True
>>> AbsMin < None
# Output: True
>>> AbsMin < ''
# Output: True
>>> from sys import maxsize
>>> AbsMin() < -maxsize
True
>>> AbsMin() < None
True
>>> AbsMin() < ''
True
"""

def __le__(self, other: Any):
Expand Down
8 changes: 4 additions & 4 deletions src/validators/between.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def between(
Examples:
>>> from datetime import datetime
>>> between(5, min_val=2)
# Output: True
True
>>> between(13.2, min_val=13, max_val=14)
# Output: True
True
>>> between(500, max_val=400)
# Output: ValidationError(func=between, args=...)
ValidationError(func=between, args={'value': 500, 'max_val': 400})
>>> between(
... datetime(2000, 11, 11),
... min_val=datetime(1999, 11, 11)
... )
# Output: True
True

Args:
value:
Expand Down
32 changes: 16 additions & 16 deletions src/validators/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def card_number(value: str, /):

Examples:
>>> card_number('4242424242424242')
# Output: True
True
>>> card_number('4242424242424241')
# Output: ValidationError(func=card_number, args={'value': '4242424242424241'})
ValidationError(func=card_number, args={'value': '4242424242424241'})

Args:
value:
Expand All @@ -46,9 +46,9 @@ def visa(value: str, /):

Examples:
>>> visa('4242424242424242')
# Output: True
True
>>> visa('2223003122003222')
# Output: ValidationError(func=visa, args={'value': '2223003122003222'})
ValidationError(func=visa, args={'value': '2223003122003222'})

Args:
value:
Expand All @@ -68,9 +68,9 @@ def mastercard(value: str, /):

Examples:
>>> mastercard('5555555555554444')
# Output: True
True
>>> mastercard('4242424242424242')
# Output: ValidationError(func=mastercard, args={'value': '4242424242424242'})
ValidationError(func=mastercard, args={'value': '4242424242424242'})

Args:
value:
Expand All @@ -90,9 +90,9 @@ def amex(value: str, /):

Examples:
>>> amex('378282246310005')
# Output: True
True
>>> amex('4242424242424242')
# Output: ValidationError(func=amex, args={'value': '4242424242424242'})
ValidationError(func=amex, args={'value': '4242424242424242'})

Args:
value:
Expand All @@ -112,9 +112,9 @@ def unionpay(value: str, /):

Examples:
>>> unionpay('6200000000000005')
# Output: True
True
>>> unionpay('4242424242424242')
# Output: ValidationError(func=unionpay, args={'value': '4242424242424242'})
ValidationError(func=unionpay, args={'value': '4242424242424242'})

Args:
value:
Expand All @@ -134,9 +134,9 @@ def diners(value: str, /):

Examples:
>>> diners('3056930009020004')
# Output: True
True
>>> diners('4242424242424242')
# Output: ValidationError(func=diners, args={'value': '4242424242424242'})
ValidationError(func=diners, args={'value': '4242424242424242'})

Args:
value:
Expand All @@ -156,9 +156,9 @@ def jcb(value: str, /):

Examples:
>>> jcb('3566002020360505')
# Output: True
True
>>> jcb('4242424242424242')
# Output: ValidationError(func=jcb, args={'value': '4242424242424242'})
ValidationError(func=jcb, args={'value': '4242424242424242'})

Args:
value:
Expand All @@ -178,9 +178,9 @@ def discover(value: str, /):

Examples:
>>> discover('6011111111111117')
# Output: True
True
>>> discover('4242424242424242')
# Output: ValidationError(func=discover, args={'value': '4242424242424242'})
ValidationError(func=discover, args={'value': '4242424242424242'})

Args:
value:
Expand Down
18 changes: 9 additions & 9 deletions src/validators/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ def calling_code(value: str, /):

Examples:
>>> calling_code('+91')
# Output: True
True
>>> calling_code('-31')
# Output: ValidationError(func=calling_code, args={'value': '-31'})
ValidationError(func=calling_code, args={'value': '-31'})

Args:
value:
Expand All @@ -273,15 +273,15 @@ def country_code(value: str, /, *, iso_format: str = "auto", ignore_case: bool =

Examples:
>>> country_code('GB', iso_format='alpha3')
# Output: False
ValidationError(func=country_code, args={'value': 'GB', 'iso_format': 'alpha3'})
>>> country_code('USA')
# Output: True
True
>>> country_code('840', iso_format='numeric')
# Output: True
True
>>> country_code('iN', iso_format='alpha2')
# Output: False
ValidationError(func=country_code, args={'value': 'iN', 'iso_format': 'alpha2'})
>>> country_code('ZWE', iso_format='alpha3')
# Output: True
True

Args:
value:
Expand Down Expand Up @@ -327,9 +327,9 @@ def currency(value: str, /, *, skip_symbols: bool = True, ignore_case: bool = Fa

Examples:
>>> currency('USD')
# Output: True
True
>>> currency('ZWX')
# Output: ValidationError(func=currency, args={'value': 'ZWX'})
ValidationError(func=currency, args={'value': 'ZWX'})

Args:
value:
Expand Down
4 changes: 2 additions & 2 deletions src/validators/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def cron(value: str, /):

Examples:
>>> cron('*/5 * * * *')
# Output: True
True
>>> cron('30-20 * * * *')
# Output: ValidationError(func=cron, ...)
ValidationError(func=cron, args={'value': '30-20 * * * *'})

Args:
value:
Expand Down
6 changes: 3 additions & 3 deletions src/validators/crypto_addresses/bsc_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def bsc_address(value: str, /):

Examples:
>>> bsc_address('0x4e5acf9684652BEa56F2f01b7101a225Ee33d23f')
# Output: True
True
>>> bsc_address('0x4g5acf9684652BEa56F2f01b7101a225Eh33d23z')
# Output: ValidationError(func=bsc_address, args=...)
ValidationError(func=bsc_address, args={'value': '0x4g5acf9684652BEa56F2f01b7101a225Eh33d23z'})

Args:
value:
Expand All @@ -26,7 +26,7 @@ def bsc_address(value: str, /):
Returns:
(Literal[True]): If `value` is a valid bsc address.
(ValidationError): If `value` is an invalid bsc address.
"""
""" # noqa: E501
if not value:
return False

Expand Down
4 changes: 2 additions & 2 deletions src/validators/crypto_addresses/btc_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def btc_address(value: str, /):

Examples:
>>> btc_address('3Cwgr2g7vsi1bXDUkpEnVoRLA9w4FZfC69')
# Output: True
True
>>> btc_address('1BvBMsEYstWetqTFn5Au4m4GFg7xJaNVN2')
# Output: ValidationError(func=btc_address, args=...)
ValidationError(func=btc_address, args={'value': '1BvBMsEYstWetqTFn5Au4m4GFg7xJaNVN2'})

Args:
value:
Expand Down
6 changes: 3 additions & 3 deletions src/validators/crypto_addresses/eth_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def eth_address(value: str, /):

Examples:
>>> eth_address('0x9cc14ba4f9f68ca159ea4ebf2c292a808aaeb598')
# Output: True
True
>>> eth_address('0x8Ba1f109551bD432803012645Ac136ddd64DBa72')
# Output: ValidationError(func=eth_address, args=...)
ValidationError(func=eth_address, args={'value': '0x8Ba1f109551bD432803012645Ac136ddd64DBa72'})

Args:
value:
Expand All @@ -49,7 +49,7 @@ def eth_address(value: str, /):
Returns:
(Literal[True]): If `value` is a valid ethereum address.
(ValidationError): If `value` is an invalid ethereum address.
"""
""" # noqa: E501
if not _keccak_flag:
raise ImportError(
"Do `pip install validators[crypto-eth-addresses]` to perform `eth_address` validation."
Expand Down
4 changes: 2 additions & 2 deletions src/validators/crypto_addresses/trx_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def trx_address(value: str, /):

Examples:
>>> trx_address('TLjfbTbpZYDQ4EoA4N5CLNgGjfbF8ZWz38')
# Output: True
True
>>> trx_address('TR2G7Rm4vFqF8EpY4U5xdLdQ7XgJ2U8Vd')
# Output: ValidationError(func=trx_address, args=...)
ValidationError(func=trx_address, args={'value': 'TR2G7Rm4vFqF8EpY4U5xdLdQ7XgJ2U8Vd'})

Args:
value:
Expand Down
6 changes: 3 additions & 3 deletions src/validators/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def domain(

Examples:
>>> domain('example.com')
# Output: True
True
>>> domain('example.com/')
# Output: ValidationError(func=domain, ...)
ValidationError(func=domain, args={'value': 'example.com/'})
>>> # Supports IDN domains as well::
>>> domain('xn----gtbspbbmkef.xn--p1ai')
# Output: True
True

Args:
value:
Expand Down
4 changes: 2 additions & 2 deletions src/validators/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def email(

Examples:
>>> email('[email protected]')
# Output: True
True
>>> email('bogus@@')
# Output: ValidationError(email=email, args={'value': 'bogus@@'})
ValidationError(func=email, args={'value': 'bogus@@'})

Args:
value:
Expand Down
16 changes: 8 additions & 8 deletions src/validators/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def base16(value: str, /):

Examples:
>>> base16('a3f4b2')
# Output: True
True
>>> base16('a3f4Z1')
# Output: ValidationError(func=base16, args={'value': 'a3f4Z1'})
ValidationError(func=base16, args={'value': 'a3f4Z1'})

Args:
value:
Expand All @@ -34,9 +34,9 @@ def base32(value: str, /):

Examples:
>>> base32('MFZWIZLTOQ======')
# Output: True
True
>>> base32('MfZW3zLT9Q======')
# Output: ValidationError(func=base32, args={'value': 'MfZW3zLT9Q======'})
ValidationError(func=base32, args={'value': 'MfZW3zLT9Q======'})

Args:
value:
Expand All @@ -55,9 +55,9 @@ def base58(value: str, /):

Examples:
>>> base58('14pq6y9H2DLGahPsM4s7ugsNSD2uxpHsJx')
# Output: True
True
>>> base58('cUSECm5YzcXJwP')
# Output: ValidationError(func=base58, args={'value': 'cUSECm5YzcXJwP'})
True

Args:
value:
Expand All @@ -76,9 +76,9 @@ def base64(value: str, /):

Examples:
>>> base64('Y2hhcmFjdGVyIHNldA==')
# Output: True
True
>>> base64('cUSECm5YzcXJwP')
# Output: ValidationError(func=base64, args={'value': 'cUSECm5YzcXJwP'})
ValidationError(func=base64, args={'value': 'cUSECm5YzcXJwP'})

Args:
value:
Expand Down
Loading
Loading