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
8.4.0: test suite uses random2 #1454
Comments
@kloczek That is correct and expected. We had to use In order to remove |
python 2 is already 1.5 year EOSed https://www.python.org/doc/sunset-python-2/
On python 3.8.9 only that one unit is failing. |
@kloczek Feel free to send a Pull Request, I'll be happy to review and remove the dependency :) |
I looked into this issue today.
diff --git a/tests/providers/test_ssn.py b/tests/providers/test_ssn.py
index acb82caa..8f4fb03f 100644
--- a/tests/providers/test_ssn.py
+++ b/tests/providers/test_ssn.py
@@ -7,7 +7,7 @@ from unittest import mock
import freezegun
import pytest
-import random2
+import random
from validators.i18n.es import es_cif as is_cif
from validators.i18n.es import es_nie as is_nie
@@ -275,7 +275,7 @@ class TestEnUS(unittest.TestCase):
assert area != '666'
def test_invalid_ssn(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
# Magic Numbers below generate '666-92-7944', '000-54-2963', '956-GG-9478', '436-00-1386',
# and 134-76-0000 respectively. The "group" (GG) returned for '956-GG-9478 will be a random
# number, and that random number is not in the "itin_group_numbers" List. The random GG occurs
@@ -603,7 +603,7 @@ class TestEtEE(unittest.TestCase):
@freezegun.freeze_time('2019-03-11')
def test_ssn(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn()
@@ -618,7 +618,7 @@ class TestEtEE(unittest.TestCase):
@freezegun.freeze_time('2002-01-01')
def test_ssn_2000(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn(min_age=0, max_age=1)
@@ -627,7 +627,7 @@ class TestEtEE(unittest.TestCase):
@freezegun.freeze_time('2101-01-01')
def test_ssn_2100(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn(min_age=0, max_age=1) However, two tests fail with this change. In
and in
I don't know the faker project well enough to know how to resolve this. In particular, I don't understand the lines in the test suite like |
I've updated that patch against 11.0.0 --- a/tests/providers/test_ssn.py~ 2021-12-27 17:58:34.000000000 +0000
+++ b/tests/providers/test_ssn.py 2021-12-27 20:28:23.710907091 +0000
@@ -8,7 +8,7 @@
import freezegun
import pytest
-import random2
+import random
from validators.i18n.es import es_cif as is_cif
from validators.i18n.es import es_nie as is_nie
@@ -278,7 +278,7 @@
assert area != "666"
def test_invalid_ssn(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
# Magic Numbers below generate '666-92-7944', '000-54-2963', '956-GG-9478', '436-00-1386',
# and 134-76-0000 respectively. The "group" (GG) returned for '956-GG-9478 will be a random
# number, and that random number is not in the "itin_group_numbers" List. The random GG occurs
@@ -659,7 +659,7 @@
@freezegun.freeze_time("2019-03-11")
def test_ssn(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn()
@@ -674,7 +674,7 @@
@freezegun.freeze_time("2002-01-01")
def test_ssn_2000(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn(min_age=0, max_age=1)
@@ -683,7 +683,7 @@
@freezegun.freeze_time("2101-01-01")
def test_ssn_2100(self):
- self.fake.random = random2.Random()
+ self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn(min_age=0, max_age=1) However as same as in your case pytaest fails with that patch ================================================================================= FAILURES =================================================================================
________________________________________________________________________ TestEnUS.test_invalid_ssn _________________________________________________________________________
self = <tests.providers.test_ssn.TestEnUS testMethod=test_invalid_ssn>
def test_invalid_ssn(self):
self.fake.random = random.Random()
# Magic Numbers below generate '666-92-7944', '000-54-2963', '956-GG-9478', '436-00-1386',
# and 134-76-0000 respectively. The "group" (GG) returned for '956-GG-9478 will be a random
# number, and that random number is not in the "itin_group_numbers" List. The random GG occurs
# even when using the same seed_instance() due to using random.choice() for GG to avoid valid
# ITINs being returned as an invalid SSN:
#
# Ensure that generated SSNs are 11 characters long
# including dashes, consist of dashes and digits only, and the tested number
# violates the requirements below, ensuring an INVALID SSN is returned:
#
# A United States Social Security Number
# (SSN) is a tax processing number issued by the Internal
# Revenue Service with the format "AAA-GG-SSSS". The
# number is divided into three parts: the first three
# digits, known as the area number because they were
# formerly assigned by geographical region; the middle two
# digits, known as the group number; and the final four
# digits, known as the serial number. SSNs with the
# following characteristics are not allocated:
#
# 1) Numbers with all zeros in any digit group
# (000-##-####, ###-00-####, ###-##-0000).
#
# 2) Numbers with 666 or 900-999 in the first digit group.
#
# https://en.wikipedia.org/wiki/Social_Security_number
#
# ITIN explained:
# https://www.irs.gov/individuals/international-taxpayers/general-itin-information
itin_group_numbers = [
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
90,
91,
92,
94,
95,
96,
97,
98,
99,
]
self.fake.seed_instance(1143)
ssn = self.fake.ssn(taxpayer_identification_number_type="INVALID_SSN")
assert len(ssn) == 11
assert ssn.replace("-", "").isdigit()
> assert ssn.startswith("666")
E AssertionError: assert False
E + where False = <built-in method startswith of str object at 0x7f8a58411e30>('666')
E + where <built-in method startswith of str object at 0x7f8a58411e30> = '682-80-0000'.startswith
tests/providers/test_ssn.py:348: AssertionError
____________________________________________________________________________ TestEtEE.test_ssn _____________________________________________________________________________
self = <tests.providers.test_ssn.TestEtEE testMethod=test_ssn>
@freezegun.freeze_time("2019-03-11")
def test_ssn(self):
self.fake.random = random.Random()
self.fake.seed_instance(0)
value = self.fake.ssn()
assert re.search(r"^\d{11}$", value)
> assert not value.endswith("0")
E AssertionError: assert not True
E + where True = <built-in method endswith of str object at 0x7f8a57eab030>('0')
E + where <built-in method endswith of str object at 0x7f8a57eab030> = '46808220410'.endswith
tests/providers/test_ssn.py:667: AssertionError
============================================================================= warnings summary =============================================================================
tests/test_factory.py::FactoryTestCase::test_documentor
/home/tkloczko/rpmbuild/BUILDROOT/python-faker-11.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/documentor.py:107: UserWarning: No appropriate country for country code AA
warnings.warn(str(e))
tests/test_factory.py::FactoryTestCase::test_documentor
/usr/lib/python3.8/site-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory
warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
tests/test_factory.py::FactoryTestCase::test_documentor
tests/test_providers_formats.py::test_no_invalid_formats[fr_QC]
/home/tkloczko/rpmbuild/BUILDROOT/python-faker-11.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/providers/person/fr_QC/__init__.py:10: UserWarning: fr_QC locale is deprecated. Please use fr_CA.
warnings.warn("fr_QC locale is deprecated. Please use fr_CA.")
tests/test_factory.py::FactoryTestCase::test_documentor
/home/tkloczko/rpmbuild/BUILDROOT/python-faker-11.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/documentor.py:107: UserWarning: No appropriate country for country code QC
warnings.warn(str(e))
tests/test_factory.py::FactoryTestCase::test_documentor
/home/tkloczko/rpmbuild/BUILDROOT/python-faker-11.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/faker/documentor.py:107: UserWarning: Country code cannot be determined from locale
warnings.warn(str(e))
-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/providers/test_address.py:428: could not import 'ukpostcodeparser.parser': No module named 'ukpostcodeparser'
SKIPPED [2] tests/pytest/session_overrides/session_locale/test_autouse_faker_locale.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified.
SKIPPED [2] tests/pytest/session_overrides/session_locale/test_autouse_faker_seed.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified.
SKIPPED [4] tests/pytest/session_overrides/session_locale/test_manual_injection.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified.
FAILED tests/providers/test_ssn.py::TestEnUS::test_invalid_ssn - AssertionError: assert False
FAILED tests/providers/test_ssn.py::TestEtEE::test_ssn - AssertionError: assert not True
===================================================== 2 failed, 1309 passed, 9 skipped, 6 warnings in 65.39s (0:01:05) ===================================================== |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Looks like pytest based tewst suite is trying to use random2 which is not maintained since 2013.
The text was updated successfully, but these errors were encountered: