Repository: joke2k/faker

Issue:
`invalid_ssn` provider doesn't yield reproducible values with the same seed
* Faker version: 2.0.1
* OS: macOS 10.14.6

The `invalid_ssn` provider doesn't yield reproducible values when used with the same random seed. It's not immediately noticeable but it does show up if you generate a number of values.

### Steps to reproduce

```
Python 3.7.2 (default, Aug 29 2019, 16:32:19) 
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from faker import Faker
>>> f1 = Faker()
>>> f2 = Faker()
>>> f1.seed_instance(1); f2.seed_instance(1)
<faker.generator.Generator object at 0x10e36dcf8>
<faker.generator.Generator object at 0x10e286320>
>>> f1.invalid_ssn()
'137-97-0000'
>>> f2.invalid_ssn()
'137-97-0000'
>>> [f1.invalid_ssn() for _ in range(1000)] == [f2.invalid_ssn() for _ in range(1000)]
False
>>> f1.seed_instance(1); f2.seed_instance(1)
<faker.generator.Generator object at 0x10e36dcf8>
<faker.generator.Generator object at 0x10e286320>
>>> while True:
...   a = f1.invalid_ssn()
...   b = f2.invalid_ssn()
...   if a != b:
...     print(f"{a} != {b}")
...     break
... 
923-67-5200 != 923-69-5200
```

### Expected behavior

With the same seed `invalid_ssn` should yield the same series of values.

### Actual behavior

The series of values differ.

From briefly looking at the code I'd guess the problem is the use of `random.choice` here which would use the global RNG instead of the instance RNG:
https://github.com/joke2k/faker/blob/cfffeb82086db9d8519c8db4f93b833316062629/faker/providers/ssn/en_US/__init__.py#L199 



Discussion:
Thank you @luser , nice catch!

Would you mind submitting a Pull Request?

Resolving patch:
diff --git a/faker/providers/ssn/en_US/__init__.py b/faker/providers/ssn/en_US/__init__.py
--- a/faker/providers/ssn/en_US/__init__.py
+++ b/faker/providers/ssn/en_US/__init__.py
@@ -1,7 +1,6 @@
 # coding=utf-8
 from __future__ import unicode_literals
 
-import random
 from .. import Provider as BaseProvider
 
 
@@ -28,7 +27,7 @@ def itin(self):
         serial = self.random_int(min=0, max=9999)
 
         # The group number must be between 70 and 99 inclusively but not 89 or 93
-        group = random.choice([x for x in range(70, 100) if x not in [89, 93]])
+        group = self.random_element([x for x in range(70, 100) if x not in [89, 93]])
 
         itin = "{0:03d}-{1:02d}-{2:04d}".format(area, group, serial)
         return itin
@@ -134,7 +133,7 @@ def ein(self):
             '98',
             '99']
 
-        ein_prefix = random.choice(ein_prefix_choices)
+        ein_prefix = self.random_element(ein_prefix_choices)
         sequence = self.random_int(min=0, max=9999999)
 
         ein = "{0:s}-{1:07d}".format(ein_prefix, sequence)
@@ -196,7 +195,7 @@ def invalid_ssn(self):
             group = self.random_int(0, 99)
             serial = self.random_int(0, 9999)
         else:
-            group = random.choice([x for x in range(0, 100) if x not in itin_group_numbers])
+            group = self.random_element([x for x in range(0, 100) if x not in itin_group_numbers])
             serial = self.random_int(0, 9999)
 
         invalid_ssn = "{0:03d}-{1:02d}-{2:04d}".format(area, group, serial)


Test patch: