Repository: joke2k/faker

Issue:
pt_BR email not returning valid email addresses
When creating a fake Factory with the pt_BR it is not returning valid email addresses.
Example:
```
melocauã@bol.com.br
joão-gabrielferreira@ig.com.br
lavíniarodrigues@sales.org
vitória78@example.br
```


Discussion:
Same kind of issue as #455. It's not a country/language specific issue. 

Also mentioned in #490
Although it is generally not advised to have "weird" characters in email address, they are not forbidden by the specification (see for instance [this](https://davidcel.is/posts/stop-validating-email-addresses-with-regex/) or [that](https://en.wikipedia.org/wiki/Email_address#Local-part)).

However, this is so rare and unsupported by a lot of platforms that faker should probably generate only ascii email addresses…
I would accept a PR, if anybody is willing to work on it
@fcurella I am tempted to work on a PR addressing this issue.  Would slugify from faker/utils/text.py be the proper place to tackle?
@clarmso thank you for volunteering! What's needed is a 'replacements' attribute on the provider, such as in https://github.com/joke2k/faker/blob/master/faker/providers/internet/fr_FR/__init__.py#L12

Could you also add the same to pt_PT? I would assume they would need the same replacements
@clarmso @fcurella

Found this bug in my tests, last place that i checked was Faker, a lot of time wasted...
my 2 cents, escape all latin1 https://unicodelookup.com/#latin
can work on a PR if @clarmso doesn't have the time.
```python
replacements = (
    ('À', 'a'), ('Á', 'a'), ('Â', 'a'), ('Ã', 'a'), ('Ä', 'a'), ('Å', 'a'),
    ('à', 'a'), ('á', 'a'), ('â', 'a'), ('ã', 'a'), ('ä', 'a'), ('å', 'a'),
    ('Ç', 'c'), ('ç', 'c'),
    ('Ñ', 'n'),
    ('È', 'e'), ('É', 'e'), ('Ê', 'e'), ('Ë', 'e'),
    ('è', 'e'), ('é', 'e'), ('ê', 'e'), ('ë', 'e'),
    ('Ì', 'i'), ('Í', 'i'), ('Î', 'i'), ('Ï', 'i'),
    ('ì', 'i'), ('í', 'i'), ('î', 'i'), ('ï', 'i'),
    ('Ò', 'o'), ('Ó', 'o'), ('Ô', 'o'), ('Õ', 'o'), ('Ö', 'o'), ('Ø', 'o'),
    ('Ù', 'u'), ('Ú', 'u'), ('Û', 'u'), ('Ü', 'u'),
    ('Ý', 'y'),
    ('Æ', 'ae'),
    ('Ð', 'eth'),
    ('Þ', 'thorn'),
    ('ß', 'sharp'),
    ('æ', 'ae'),
    ('ð', 'eth'),
)
```

Resolving patch:
diff --git a/faker/providers/internet/pt_BR/__init__.py b/faker/providers/internet/pt_BR/__init__.py
--- a/faker/providers/internet/pt_BR/__init__.py
+++ b/faker/providers/internet/pt_BR/__init__.py
@@ -13,3 +13,11 @@ class Provider(InternetProvider):
         'bol.com.br',
         'ig.com.br')
     tlds = ('com', 'com', 'com', 'net', 'org', 'br', 'br', 'br')
+    replacements = (
+        ('à', 'a'), ('â', 'a'), ('ã', 'a'),
+        ('ç', 'c'),
+        ('é', 'e'), ('ê', 'e'),
+        ('í', 'i'),
+        ('ô', 'o'), ('ö', 'o'), ('õ', 'o'),
+        ('ú', 'u'),
+    )


Test patch:
diff --git a/tests/providers/test_internet.py b/tests/providers/test_internet.py
--- a/tests/providers/test_internet.py
+++ b/tests/providers/test_internet.py
@@ -202,3 +202,37 @@ def test_ascii_company_email(self):
         email = self.factory.ascii_company_email()
         validate_email(email, check_deliverability=False)
         self.assertEqual(email.split('@')[0], 'asyl')
+
+
+class TestPtBR(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Faker('pt_BR')
+        self.provider = self.factory.provider('faker.providers.internet')
+
+    @mock.patch(
+        'faker.providers.internet.Provider.user_name',
+        lambda x: 'VitóriaMagalhães'
+    )
+    def test_ascii_safe_email(self):
+        email = self.factory.ascii_safe_email()
+        validate_email(email, check_deliverability=False)
+        self.assertEqual(email.split('@')[0], 'vitoriamagalhaes')
+
+    @mock.patch(
+        'faker.providers.internet.Provider.user_name',
+        lambda x: 'JoãoSimões'
+    )
+    def test_ascii_free_email(self):
+        email = self.factory.ascii_free_email()
+        validate_email(email, check_deliverability=False)
+        self.assertEqual(email.split('@')[0], 'joaosimoes')
+
+    @mock.patch(
+        'faker.providers.internet.Provider.user_name',
+        lambda x: 'AndréCauã'
+    )
+    def test_ascii_company_email(self):
+        email = self.factory.ascii_company_email()
+        validate_email(email, check_deliverability=False)
+        self.assertEqual(email.split('@')[0], 'andrecaua')