Repository: joke2k/faker
Pull request #1256 (2020-09-01 12:40:40)

Test Suite Housekeeping (Part 5)
### What does this change

Just another round of pytestifying, and a minor fix for the `pt_BR` phone provider.

Related to #1162

fcurella: Thank you!

Patch:
diff --git a/faker/providers/phone_number/pt_BR/__init__.py b/faker/providers/phone_number/pt_BR/__init__.py
index e425a455..46b1fb0b 100644
--- a/faker/providers/phone_number/pt_BR/__init__.py
+++ b/faker/providers/phone_number/pt_BR/__init__.py
@@ -16,7 +16,7 @@ class Provider(PhoneNumberProvider):
         '+55 21 #### ####',
         '+55 31 #### ####',
         '+55 41 #### ####',
-        '+55 51 ### ####',
+        '+55 51 #### ####',
         '+55 61 #### ####',
         '+55 71 #### ####',
         '+55 81 #### ####',
@@ -34,7 +34,7 @@ class Provider(PhoneNumberProvider):
         '+55 21 ####-####',
         '+55 31 ####-####',
         '+55 41 ####-####',
-        '+55 51 ### ####',
+        '+55 51 #### ####',
         '+55 61 ####-####',
         '+55 71 ####-####',
         '+55 81 ####-####',
@@ -52,7 +52,7 @@ class Provider(PhoneNumberProvider):
         '21 #### ####',
         '31 #### ####',
         '41 #### ####',
-        '51 ### ####',
+        '51 #### ####',
         '61 #### ####',
         '71 #### ####',
         '81 #### ####',
@@ -70,7 +70,7 @@ class Provider(PhoneNumberProvider):
         '21 ####-####',
         '31 ####-####',
         '41 ####-####',
-        '51 ### ####',
+        '51 #### ####',
         '61 ####-####',
         '71 ####-####',
         '81 ####-####',


Test patch:
diff --git a/tests/providers/test_color.py b/tests/providers/test_color.py
index 1c673864..fd65d6a2 100644
--- a/tests/providers/test_color.py
+++ b/tests/providers/test_color.py
@@ -1,147 +1,139 @@
 import copy
 import random
 import re
-import unittest
 
-from re import search
+import pytest
 
-from faker import Faker
 from faker.providers.color import RandomColor
-from faker.providers.color.es_ES import Provider as EsEsProvider
-from faker.providers.color.fa_IR import Provider as FaIrProvider
-from faker.providers.color.hy_AM import Provider as HyAmProvider
-
-
-class TestColor(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('en_US')
-        Faker.seed(0)
-
-    def test_safe_hex_color(self):
-        assert all(search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', self.fake.safe_hex_color()) for _ in range(1000))
-
-    def test_hex_color(self):
-        assert all(search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', self.fake.hex_color()) for _ in range(1000))
-
-    def test_rgb_color(self):
-        maxval = 0
-        minval = 0
-
-        for _ in range(1000):
-            current = list(map(int, self.fake.rgb_color().split(',')))
-            if max(current) > maxval:
-                maxval = max(current)
-            if min(current) > minval:
-                minval = min(current)
-
-        assert maxval <= 255
-        assert minval >= 0
-
-    def test_rgb_css_color(self):
-        maxval = 0
-        minval = 0
-
-        for _ in range(1000):
-            current = list(map(int, self.fake.rgb_css_color()[4:-1].split(',')))
-            if max(current) > maxval:
-                maxval = max(current)
-            if min(current) > minval:
-                minval = min(current)
-
-        assert maxval <= 255
-        assert minval >= 0
-
-    def test_color(self):
+from faker.providers.color.es_ES import Provider as EsEsColorProvider
+from faker.providers.color.fa_IR import Provider as FaIrColorProvider
+from faker.providers.color.hy_AM import Provider as HyAmColorProvider
+
+
+class TestColorProvider:
+    """Test color provider methods"""
+    num_samples = 10000
+
+    def test_safe_hex_color(self, faker, num_samples):
+        assert all(
+            re.fullmatch(r'#(?:([0-9a-f])\1){3}', faker.safe_hex_color())
+            for _ in range(num_samples)
+        )
+
+    def test_hex_color(self, faker, num_samples):
+        assert all(
+            re.fullmatch(r'#[0-9a-f]{6}', faker.hex_color())
+            for _ in range(num_samples)
+        )
+
+    def test_rgb_color(self, faker, num_samples):
+        for _ in range(num_samples):
+            r, g, b = list(map(int, faker.rgb_color().split(',')))
+            assert 0 <= r <= 255
+            assert 0 <= g <= 255
+            assert 0 <= b <= 255
+
+    def test_rgb_css_color(self, faker, num_samples):
+        pattern = re.compile(r'rgb\((?P<rgb>\d{1,3},\d{1,3},\d{1,3})\)')
+        for _ in range(num_samples):
+            match = pattern.fullmatch(faker.rgb_css_color())
+            rgb = match.group('rgb')
+            r, g, b = list(map(int, rgb.split(',')))
+            assert 0 <= r <= 255
+            assert 0 <= g <= 255
+            assert 0 <= b <= 255
+
+    def test_color(self, faker, num_samples):
         baseline_random_color = RandomColor(seed=4761)
-        expected = [baseline_random_color.generate() for _ in range(10000)]
+        expected = [baseline_random_color.generate() for _ in range(num_samples)]
 
         # The `color` provider method should behave like the `generate`
         # method of a standalone RandomColor instance for a given seed
-        Faker.seed(4761)
-        colors = [self.fake.color() for _ in range(10000)]
+        faker.seed_instance(4761)
+        colors = [faker.color() for _ in range(num_samples)]
         assert colors == expected
 
 
-class TestRandomColor(unittest.TestCase):
-
+class TestRandomColor:
+    """Test RandomColor class"""
+    num_samples = 1000
     seed = 4761
     hsv_color_pattern = re.compile(
-        r'^hsv\('
+        r'hsv\('
         r'(?P<h>\d|[1-9]\d|[1-3]\d{2}), '
         r'(?P
\d|[1-9]\d|100), '
-        r'(?P<v>\d|[1-9]\d|100)\)$',
+        r'(?P<v>\d|[1-9]\d|100)\)',
     )
     hsl_color_pattern = re.compile(
-        r'^hsl\('
+        r'hsl\('
         r'(?P<h>\d|[1-9]\d|[1-3]\d{2}), '
         r'(?P
\d|[1-9]\d|[1-3]\d{2}), '
-        r'(?P<l>\d|[1-9]\d|[1-3]\d{2})\)$',
+        r'(?P<l>\d|[1-9]\d|[1-3]\d{2})\)',
     )
     rgb_color_pattern = re.compile(
-        r'^rgb\('
+        r'rgb\('
         r'(?P<r>\d|[1-9]\d|[1-3]\d{2}), '
         r'(?P<g>\d|[1-9]\d|[1-3]\d{2}), '
-        r'(?P<b>\d|[1-9]\d|[1-3]\d{2})\)$',
+        r'(?P<b>\d|[1-9]\d|[1-3]\d{2})\)',
     )
-    hex_color_pattern = re.compile(r'^#[0-9a-f]{6}$')
+    hex_color_pattern = re.compile(r'#[0-9a-f]{6}')
 
-    def setUp(self):
+    def setup_method(self):
         self.random_color = RandomColor(seed=self.seed)
 
-    def test_color_format_hsv(self):
-        for _ in range(10000):
+    def test_color_format_hsv(self, num_samples):
+        for _ in range(num_samples):
             hsv_color = self.random_color.generate(color_format='hsv')
-            match = self.hsv_color_pattern.match(hsv_color)
+            match = self.hsv_color_pattern.fullmatch(hsv_color)
             assert match
             groupdict = match.groupdict()
             assert 0 <= int(groupdict['h']) <= 360
             assert 0 <= int(groupdict['s']) <= 100
             assert 0 <= int(groupdict['v']) <= 100
 
-    def test_color_format_hsl(self):
-        for _ in range(10000):
+    def test_color_format_hsl(self, num_samples):
+        for _ in range(num_samples):
             hsl_color = self.random_color.generate(color_format='hsl')
-            match = self.hsl_color_pattern.match(hsl_color)
+            match = self.hsl_color_pattern.fullmatch(hsl_color)
             assert match
             groupdict = match.groupdict()
             assert 0 <= int(groupdict['h']) <= 360
             assert 0 <= int(groupdict['s']) <= 100
             assert 0 <= int(groupdict['l']) <= 100
 
-    def test_color_format_rgb(self):
-        for _ in range(10000):
+    def test_color_format_rgb(self, num_samples):
+        for _ in range(num_samples):
             rgb_color = self.random_color.generate(color_format='rgb')
-            match = self.rgb_color_pattern.match(rgb_color)
+            match = self.rgb_color_pattern.fullmatch(rgb_color)
             assert match
             groupdict = match.groupdict()
             assert 0 <= int(groupdict['r']) <= 255
             assert 0 <= int(groupdict['g']) <= 255
             assert 0 <= int(groupdict['b']) <= 255
 
-    def test_color_format_hex(self):
-        for _ in range(10000):
+    def test_color_format_hex(self, num_samples):
+        for _ in range(num_samples):
             hex_color = self.random_color.generate(color_format='hex')
-            assert self.hex_color_pattern.match(hex_color)
+            assert self.hex_color_pattern.fullmatch(hex_color)
 
-    def test_color_format_unspecified(self):
-        for _ in range(10000):
+    def test_color_format_unspecified(self, num_samples):
+        for _ in range(num_samples):
             color = self.random_color.generate()
-            assert self.hex_color_pattern.match(color)
+            assert self.hex_color_pattern.fullmatch(color)
 
     def test_hue_integer(self):
         # HSV format is used, because whatever hue value supplied must be present in the output
         for hue in range(360):
             colors = [self.random_color.generate(hue=hue, color_format='hsv') for _ in range(10)]
             for color in colors:
-                match = self.hsv_color_pattern.match(color)
+                match = self.hsv_color_pattern.fullmatch(color)
                 assert match
                 groupdict = match.groupdict()
                 assert int(groupdict['h']) == hue
 
-    def test_hue_float(self):
+    def test_hue_float(self, num_samples):
         baseline_random_color = RandomColor(seed=self.seed)
-        for _ in range(1000):
+        for _ in range(num_samples):
             hue_float = random.uniform(0, 360)
             hue_int = int(hue_float)
             expected = [baseline_random_color.generate(hue=hue_int) for _ in range(10)]
@@ -184,22 +176,22 @@ class TestRandomColor(unittest.TestCase):
         colors = [self.random_color.generate(hue='pink') for _ in range(5)]
         assert colors == expected
 
-    def test_hue_tuple_beyond_limits(self):
+    def test_hue_tuple_beyond_limits(self, num_samples):
         baseline_random_color = RandomColor(seed=self.seed)
-        expected = [baseline_random_color.generate(hue=[0, 360]) for _ in range(1000)]
+        expected = [baseline_random_color.generate(hue=[0, 360]) for _ in range(num_samples)]
 
         # Using a tuple with values not between 0 and 360 should yield the same results
         # as using a tuple with clamped values for a given seed
-        colors = [self.random_color.generate(hue=[-100, 4500]) for _ in range(1000)]
+        colors = [self.random_color.generate(hue=[-100, 4500]) for _ in range(num_samples)]
         assert colors == expected
 
-    def test_hue_tuple_inverted_values(self):
+    def test_hue_tuple_inverted_values(self, num_samples):
         baseline_random_color = RandomColor(seed=self.seed)
-        expected = [baseline_random_color.generate(hue=[45, 75]) for _ in range(1000)]
+        expected = [baseline_random_color.generate(hue=[45, 75]) for _ in range(num_samples)]
 
         # Using a tuple with inverted values should yield the same results
         # as using the correctly ordered tuple for a given seed
-        colors = [self.random_color.generate(hue=[75, 45]) for _ in range(1000)]
+        colors = [self.random_color.generate(hue=[75, 45]) for _ in range(num_samples)]
         assert colors == expected
 
     def test_hue_invalid(self):
@@ -213,7 +205,7 @@ class TestRandomColor(unittest.TestCase):
         ]
 
         for invalid_value in invalid_values:
-            with self.assertRaises(TypeError):
+            with pytest.raises(TypeError):
                 self.random_color.generate(hue=invalid_value)
 
     def test_luminosity_word(self):
@@ -233,11 +225,11 @@ class TestRandomColor(unittest.TestCase):
         colors = [self.random_color.generate(luminosity='random') for _ in range(5)]
         assert colors == expected
 
-    def test_luminosity_invalid(self):
+    def test_luminosity_invalid(self, num_samples):
         baseline_random_color = RandomColor(seed=self.seed)
-        expected = [baseline_random_color.generate() for _ in range(1000)]
+        expected = [baseline_random_color.generate() for _ in range(num_samples)]
 
-        colors = [self.random_color.generate(luminosity='invalid_value') for _ in range(1000)]
+        colors = [self.random_color.generate(luminosity='invalid_value') for _ in range(num_samples)]
         assert colors == expected
 
     def test_bad_color_map(self):
@@ -248,59 +240,53 @@ class TestRandomColor(unittest.TestCase):
         colormap = copy.deepcopy(self.random_color.colormap)
         colormap['yellow']['hue_range'] = [47, 61]
         self.random_color.colormap = colormap
-        with self.assertRaises(ValueError):
+        with pytest.raises(ValueError):
             self.random_color.generate(hue=62)
 
 
-class TestHyAM(unittest.TestCase):
-    """ Tests colors in the hy_AM locale """
-
-    def setUp(self):
-        self.fake = Faker('hy_AM')
-        Faker.seed(0)
-
-    def test_color_name(self):
-        color_name = self.fake.color_name()
-        assert isinstance(color_name, str)
-        assert color_name in HyAmProvider.all_colors.keys()
-
-    def test_safe_color_name(self):
-        safe_color_name = self.fake.safe_color_name()
-        assert isinstance(safe_color_name, str)
-        assert safe_color_name in HyAmProvider.safe_colors
+class TestHyAm:
+    """Test hy_AM color provider methods"""
 
+    def test_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            color_name = faker.color_name()
+            assert isinstance(color_name, str)
+            assert color_name in HyAmColorProvider.all_colors.keys()
 
-class TestFaIr(unittest.TestCase):
-    """ Tests colors in the fa_IR locale """
+    def test_safe_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            safe_color_name = faker.safe_color_name()
+            assert isinstance(safe_color_name, str)
+            assert safe_color_name in HyAmColorProvider.safe_colors
 
-    def setUp(self):
-        self.fake = Faker('fa_IR')
-        Faker.seed(0)
 
-    def test_color_name(self):
-        color_name = self.fake.color_name()
-        assert isinstance(color_name, str)
-        assert color_name in FaIrProvider.all_colors.keys()
+class TestFaIr:
+    """Test fa_IR color provider methods"""
 
-    def test_safe_color_name(self):
-        safe_color_name = self.fake.safe_color_name()
-        assert isinstance(safe_color_name, str)
-        assert safe_color_name in FaIrProvider.safe_colors
+    def test_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            color_name = faker.color_name()
+            assert isinstance(color_name, str)
+            assert color_name in FaIrColorProvider.all_colors.keys()
 
+    def test_safe_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            safe_color_name = faker.safe_color_name()
+            assert isinstance(safe_color_name, str)
+            assert safe_color_name in FaIrColorProvider.safe_colors
 
-class TestEsES(unittest.TestCase):
-    """ Tests colors in the es_ES locale """
 
-    def setUp(self):
-        self.fake = Faker('es_ES')
-        Faker.seed(0)
+class TestEsEs:
+    """Test es_ES color provider methods"""
 
-    def test_color_name(self):
-        color_name = self.fake.color_name()
-        assert isinstance(color_name, str)
-        assert color_name in EsEsProvider.all_colors.keys()
+    def test_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            color_name = faker.color_name()
+            assert isinstance(color_name, str)
+            assert color_name in EsEsColorProvider.all_colors.keys()
 
-    def test_safe_color_name(self):
-        safe_color_name = self.fake.safe_color_name()
-        assert isinstance(safe_color_name, str)
-        assert safe_color_name in EsEsProvider.safe_colors
+    def test_safe_color_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            safe_color_name = faker.safe_color_name()
+            assert isinstance(safe_color_name, str)
+            assert safe_color_name in EsEsColorProvider.safe_colors
diff --git a/tests/providers/test_company.py b/tests/providers/test_company.py
index 4d248d7e..d4c828ea 100644
--- a/tests/providers/test_company.py
+++ b/tests/providers/test_company.py
@@ -1,129 +1,128 @@
 import re
-import unittest
 
-from faker import Faker
-from faker.providers.company.hy_AM import Provider as HyAmProvider
-from faker.providers.company.ja_JP import Provider as JaProvider
-from faker.providers.company.nl_NL import Provider as NlProvider
-from faker.providers.company.pl_PL import Provider as PlProvider
+from faker.providers.company.en_PH import Provider as EnPhCompanyProvider
+from faker.providers.company.fil_PH import Provider as FilPhCompanyProvider
+from faker.providers.company.hu_HU import Provider as HuHuCompanyProvider
+from faker.providers.company.hy_AM import Provider as HyAmCompanyProvider
+from faker.providers.company.ja_JP import Provider as JaJpCompanyProvider
+from faker.providers.company.nl_NL import Provider as NlNlCompanyProvider
+from faker.providers.company.pl_PL import Provider as PlPlCompanyProvider
 from faker.providers.company.pl_PL import company_vat_checksum, local_regon_checksum, regon_checksum
 from faker.providers.company.pt_BR import company_id_checksum
-from faker.providers.company.ru_RU import Provider as RuProvider
+from faker.providers.company.ru_RU import Provider as RuRuCompanyProvider
 from faker.providers.company.ru_RU import calculate_checksum
 from faker.utils.datetime_safe import datetime
 
 
-class TestFiFI(unittest.TestCase):
+class TestFiFi:
+    """Test fi_FI company provider methods"""
 
-    def setUp(self):
-        self.fake = Faker('fi_FI')
-        Faker.seed(0)
+    def _has_valid_checksum(self, company_id):
+        factors = [7, 9, 10, 5, 8, 4, 2]
+        checksum = 0
+        for x, y in zip(company_id[:-2], factors):
+            checksum += int(x) * y
+        checksum %= 11
+        checksum = 11 - checksum if checksum else 0
+        return int(company_id[-1]) == checksum
 
-    def test_company_business_id(self):
-        self.fake.random.seed(6)
-        company_id = self.fake.company_business_id()
-        assert company_id.endswith('0')
+    def test_company_business_id(self, faker, num_samples):
+        for _ in range(num_samples):
+            company_id = faker.company_business_id()
+            assert len(company_id) == 9
+            assert self._has_valid_checksum(company_id)
 
-        for seed in range(0, 1000):
-            Faker.seed(seed)
-            assert (len(self.fake.company_business_id()) == 9)
 
+class TestHyAm:
+    """Test hy_AM company provider methods"""
 
-class TestHyAm(unittest.TestCase):
-    """ Tests companies in the hy_AM locale """
-
-    def setUp(self):
-        self.fake = Faker('hy_AM')
-        Faker.seed(0)
-
-    def test_bs(self):
-        bs = self.fake.bs()
-        assert isinstance(bs, str)
-
-    def test_catch_phrase(self):
-        catch_phrase = self.fake.catch_phrase()
-        assert isinstance(catch_phrase, str)
-
-    def test_company(self):
-        company = self.fake.company()
-        assert isinstance(company, str)
+    def test_bs(self, faker, num_samples):
+        for _ in range(num_samples):
+            bs = faker.bs()
+            assert isinstance(bs, str)
 
-    def test_company_suffix(self):
-        suffix = self.fake.company_suffix()
-        assert isinstance(suffix, str)
-        assert suffix in HyAmProvider.company_suffixes
+    def test_catch_phrase(self, faker, num_samples):
+        for _ in range(num_samples):
+            catch_phrase = faker.catch_phrase()
+            assert isinstance(catch_phrase, str)
 
+    def test_company(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.company()
+            assert isinstance(company, str)
 
-class TestJaJP(unittest.TestCase):
-    """ Tests companies in the ja_JP locale """
+    def test_company_suffix(self, faker, num_samples):
+        for _ in range(num_samples):
+            suffix = faker.company_suffix()
+            assert isinstance(suffix, str)
+            assert suffix in HyAmCompanyProvider.company_suffixes
 
-    def setUp(self):
-        self.fake = Faker('ja')
-        Faker.seed(0)
 
-    def test_company(self):
-        prefixes = JaProvider.company_prefixes
-        prefix = self.fake.company_prefix()
-        assert isinstance(prefix, str)
-        assert prefix in prefixes
+class TestJaJp:
+    """Test ja_JP company provider methods"""
 
-        categories = JaProvider.company_categories
-        category = self.fake.company_category()
-        assert isinstance(category, str)
-        assert category in categories
+    def test_company_prefix(self, faker, num_samples):
+        for _ in range(num_samples):
+            prefix = faker.company_prefix()
+            assert isinstance(prefix, str)
+            assert prefix in JaJpCompanyProvider.company_prefixes
 
-        company = self.fake.company()
-        assert isinstance(company, str)
-        assert any(company.startswith(prefix) or company.endswith(prefix) for prefix in prefixes)
-        assert any(category in company for category in categories)
+    def test_company_category(self, faker, num_samples):
+        for _ in range(num_samples):
+            category = faker.company_category()
+            assert isinstance(category, str)
+            assert category in JaJpCompanyProvider.company_categories
 
+    def test_company(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.company()
+            assert isinstance(company, str)
+            assert any(
+                company.startswith(prefix) or company.endswith(prefix)
+                for prefix in JaJpCompanyProvider.company_prefixes
+            )
+            assert any(
+                category in company
+                for category in JaJpCompanyProvider.company_categories
+            )
 
-class TestPtBR(unittest.TestCase):
-    """ Tests company in the pt_BR locale """
 
-    def setUp(self):
-        self.fake = Faker('pt_BR')
-        Faker.seed(0)
+class TestPtBr:
+    """Test pt_BR company provider methods"""
 
-    def test_pt_BR_company_id_checksum(self):
+    def test_company_id_checksum(self):
         assert company_id_checksum([9, 4, 9, 5, 3, 4, 4, 1, 0, 0, 0, 1]) == [5, 1]
         assert company_id_checksum([1, 6, 0, 0, 4, 6, 3, 9, 0, 0, 0, 1]) == [8, 5]
 
-    def test_pt_BR_company_id(self):
-        for _ in range(100):
-            assert re.search(r'^\d{14}$', self.fake.company_id())
-
-    def test_pt_BR_cnpj(self):
-        for _ in range(100):
-            cnpj = self.fake.cnpj()
-            assert re.search(r'\d{2}\.\d{3}\.\d{3}/0001-\d{2}', cnpj)
-
+    def test_company_id(self, faker, num_samples):
+        for _ in range(num_samples):
+            company_id = faker.company_id()
+            assert re.fullmatch(r'\d{14}', company_id)
 
-class TestHuHU(unittest.TestCase):
-    """ Tests company in the hu_HU locale """
+    def test_cnpj(self, faker, num_samples):
+        for _ in range(num_samples):
+            cnpj = faker.cnpj()
+            assert re.fullmatch(r'\d{2}\.\d{3}\.\d{3}/0001-\d{2}', cnpj)
 
-    def setUp(self):
-        self.fake = Faker('hu_HU')
-        Faker.seed(0)
-        self.valid_suffixes = ('Kft.', 'Kht.', 'Zrt.', 'Bt.', 'Nyrt.', 'Kkt.')
 
-    def test_company_suffix(self):
-        suffix = self.fake.company_suffix()
-        assert isinstance(suffix, str)
-        assert suffix in self.valid_suffixes
+class TestHuHu:
+    """Test hu_HU company provider methods"""
 
-    def test_company(self):
-        company = self.fake.company()
-        assert isinstance(company, str)
-        assert company.split(" ")[-1] in self.valid_suffixes
+    def test_company_suffix(self, faker, num_samples):
+        for _ in range(num_samples):
+            suffix = faker.company_suffix()
+            assert isinstance(suffix, str)
+            assert suffix in HuHuCompanyProvider.company_suffixes
 
+    def test_company(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.company()
+            assert isinstance(company, str)
+            assert company.split(" ")[-1] in HuHuCompanyProvider.company_suffixes
 
-class TestPlPL(unittest.TestCase):
-    """ Tests company in the pl_PL locale """
 
-    def setUp(self):
-        self.fake = Faker('pl_PL')
-        Faker.seed(0)
+class TestPlPl:
+    """Test pl_PL company provider methods"""
 
     def test_regon_checksum(self):
         assert regon_checksum([1, 2, 3, 4, 5, 6, 7, 8]) == 5
@@ -132,9 +131,9 @@ class TestPlPL(unittest.TestCase):
         assert regon_checksum([7, 9, 3, 5, 4, 7, 9, 3]) == 9
         assert regon_checksum([9, 1, 5, 9, 6, 9, 4, 7]) == 7
 
-    def test_regon(self):
-        for _ in range(100):
-            assert re.search(r'^\d{9}$', self.fake.regon())
+    def test_regon(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r'\d{9}', faker.regon())
 
     def test_local_regon_checksum(self):
         assert local_regon_checksum([1, 2, 3, 4, 5, 6, 7, 8, 5, 1, 2, 3, 4]) == 7
@@ -143,9 +142,9 @@ class TestPlPL(unittest.TestCase):
         assert local_regon_checksum([3, 5, 7, 7, 1, 0, 2, 2, 2, 5, 4, 3, 3]) == 0
         assert local_regon_checksum([9, 3, 5, 3, 1, 1, 0, 1, 2, 4, 8, 8, 2]) == 1
 
-    def test_local_regon(self):
-        for _ in range(100):
-            assert re.search(r'^\d{14}$', self.fake.local_regon())
+    def test_local_regon(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r'\d{14}', faker.local_regon())
 
     def test_company_vat_checksum(self):
         assert company_vat_checksum([7, 7, 5, 7, 7, 7, 6, 0, 5]) == 9
@@ -154,118 +153,94 @@ class TestPlPL(unittest.TestCase):
         assert company_vat_checksum([3, 5, 4, 6, 1, 0, 6, 5, 8]) == 4
         assert company_vat_checksum([3, 1, 9, 5, 5, 7, 0, 4, 5]) == 0
 
-    def test_company_vat(self):
-        for _ in range(100):
-            assert re.search(r'^\d{10}$', self.fake.company_vat())
-
-    def test_company_prefix(self):
-        prefixes = PlProvider.company_prefixes
-        prefix = self.fake.company_prefix()
-        assert isinstance(prefix, str)
-        assert prefix in prefixes
-
-    def test_company_suffix(self):
-        suffixes = PlProvider.company_suffixes
-        suffix = self.fake.company_suffix()
-        assert isinstance(suffix, str)
-        assert suffix in suffixes
-
-
-class TestNlNL(unittest.TestCase):
-    """ Tests company in the nl_NL locale """
-
-    def setUp(self):
-        self.fake = Faker('nl_NL')
-        Faker.seed(0)
-
-    def test_company_prefix(self):
-        prefixes = NlProvider.company_prefixes
-        prefix = self.fake.company_prefix()
-        assert isinstance(prefix, str)
-        assert prefix in prefixes
-
-    def test_company_suffix(self):
-        suffixes = NlProvider.company_suffixes
-        suffix = self.fake.company_suffix()
-        assert isinstance(suffix, str)
-        assert suffix in suffixes
-
-    def test_large_companies(self):
-        companies = NlProvider.large_companies
-        company = self.fake.large_company()
-        assert isinstance(company, str)
-        assert company in companies
-
-
-class TestEnPh(unittest.TestCase):
-    num_sample_runs = 1000
-
-    def setUp(self):
-        self.national_corporation_pattern = re.compile(r'^National (.*?) Corporation of the Philippines$')
-        self.setup_constants()
-        self.setup_faker()
-
-    def setup_faker(self):
-        self.fake = Faker('en_PH')
-        Faker.seed(0)
-
-    def setup_constants(self):
-        from faker.providers.company.en_PH import Provider
-        self.company_types = Provider.company_types
-        self.company_suffixes = Provider.company_suffixes.keys()
-        self.company_products = Provider.company_products
-
-    def test_PH_random_company_noun_chain(self):
-        for i in range(self.num_sample_runs):
-            noun_list = self.fake.random_company_noun_chain().split()
-            assert len(noun_list) in range(1, 3)
-
-    def test_PH_random_company_acronym(self):
-        for i in range(self.num_sample_runs):
-            assert len(self.fake.random_company_acronym()) in range(2, 5)
-
-    def test_PH_company(self):
-        for i in range(self.num_sample_runs):
-            company = self.fake.company()
+    def test_company_vat(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r'\d{10}', faker.company_vat())
+
+    def test_company_prefix(self, faker, num_samples):
+        for _ in range(num_samples):
+            prefix = faker.company_prefix()
+            assert isinstance(prefix, str)
+            assert prefix in PlPlCompanyProvider.company_prefixes
+
+    def test_company_suffix(self, faker, num_samples):
+        for _ in range(num_samples):
+            suffix = faker.company_suffix()
+            assert isinstance(suffix, str)
+            assert suffix in PlPlCompanyProvider.company_suffixes
+
+
+class TestNlNl:
+    """Test nl_NL company provider methods"""
+
+    def test_company_prefix(self, faker, num_samples):
+        for _ in range(num_samples):
+            prefix = faker.company_prefix()
+            assert isinstance(prefix, str)
+            assert prefix in NlNlCompanyProvider.company_prefixes
+
+    def test_company_suffix(self, faker, num_samples):
+        for _ in range(num_samples):
+            suffix = faker.company_suffix()
+            assert isinstance(suffix, str)
+            assert suffix in NlNlCompanyProvider.company_suffixes
+
+    def test_large_companies(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.large_company()
+            assert isinstance(company, str)
+            assert company in NlNlCompanyProvider.large_companies
+
+
+class TestEnPh:
+    """Test en_PH company provider methods"""
+
+    @classmethod
+    def setup_class(cls):
+        cls.company_types = EnPhCompanyProvider.company_types
+        cls.company_suffixes = EnPhCompanyProvider.company_suffixes.keys()
+        cls.company_products = EnPhCompanyProvider.company_products
+        cls.national_corporation_pattern = re.compile(r'^National (.*?) Corporation of the Philippines$')
+
+    def test_random_company_noun_chain(self, faker, num_samples):
+        for _ in range(num_samples):
+            noun_list = faker.random_company_noun_chain().split()
+            assert 1 <= len(noun_list) <= 2
+
+    def test_random_company_acronym(self, faker, num_samples):
+        for _ in range(num_samples):
+            acronym = faker.random_company_acronym()
+            assert 2 <= len(acronym) <= 4
+
+    def test_company(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.company()
             if company.split()[-1] in self.company_suffixes and company.split()[-2] in self.company_types:
                 continue
             else:
-                national_corporation_match = self.national_corporation_pattern.match(company)
+                national_corporation_match = self.national_corporation_pattern.fullmatch(company)
                 assert national_corporation_match and national_corporation_match.group(1) in self.company_products
 
 
 class TestFilPh(TestEnPh):
+    """Test fil_PH company provider methods"""
 
-    def setup_faker(self):
-        self.fake = Faker('fil_PH')
-        Faker.seed(0)
-
-    def setup_constants(self):
-        super().setup_constants()
-        from faker.providers.company.fil_PH import Provider
-        self.good_service_adjectives = Provider.good_service_adjectives
-
-    def test_PH_random_good_service_adjective_chain(self):
-        for i in range(self.num_sample_runs):
-            adjectives = self.fake.random_good_service_adjective_chain().split(' at ')
-            assert adjectives[0] in self.good_service_adjectives and adjectives[1] in self.good_service_adjectives
+    def test_PH_random_good_service_adjective_chain(self, faker, num_samples):
+        for _ in range(num_samples):
+            adjectives = faker.random_good_service_adjective_chain().split(' at ')
+            assert all(
+                adjective in FilPhCompanyProvider.good_service_adjectives
+                for adjective in adjectives
+            )
 
 
 class TestTlPh(TestFilPh):
+    """Test tl_PH company provider methods"""
+    pass
 
-    def setup_faker(self):
-        self.fake = Faker('tl_PH')
-        Faker.seed(0)
 
-
-class TestRuRu(unittest.TestCase):
-    """ Tests company in the ru_RU locale """
-
-    num_sample_runs = 1000
-
-    def setUp(self):
-        self.fake = Faker('ru_RU')
-        Faker.seed(0)
+class TestRuRu:
+    """Test ru_RU company provider methods"""
 
     def test_calculate_checksum_nine_digits(self):
         assert calculate_checksum('164027304') == '7'
@@ -275,84 +250,74 @@ class TestRuRu(unittest.TestCase):
         assert calculate_checksum('70517081385') == '1'
         assert calculate_checksum('60307390550') == '0'
 
-    def test_businesses_inn(self):
-        for i in range(self.num_sample_runs):
-            inn = self.fake.businesses_inn()
-
+    def test_businesses_inn(self, faker, num_samples):
+        for _ in range(num_samples):
+            inn = faker.businesses_inn()
             assert len(inn) == 10
             assert calculate_checksum(inn[:9]) == inn[9]
 
-    def test_individuals_inn(self):
-        for i in range(self.num_sample_runs):
-            inn = self.fake.individuals_inn()
-
+    def test_individuals_inn(self, faker, num_samples):
+        for _ in range(num_samples):
+            inn = faker.individuals_inn()
             assert len(inn) == 12
             assert calculate_checksum(inn[:10]) == inn[10]
             assert calculate_checksum(inn[:11]) == inn[11]
 
-    def test_businesses_ogrn(self):
+    def test_businesses_ogrn(self, faker, num_samples):
         max_year = datetime.now().year - 2000
-
-        for i in range(self.num_sample_runs):
-            ogrn = self.fake.businesses_ogrn()
-
+        for _ in range(num_samples):
+            ogrn = faker.businesses_ogrn()
             assert len(ogrn) == 13
             assert ogrn[0] in ('1', '5')
             assert 1 <= int(ogrn[1:3]) <= max_year
             assert 1 <= int(ogrn[3:5]) <= 92
             assert int(ogrn[:-1]) % 11 % 10 == int(ogrn[-1])
 
-    def test_individuals_ogrn(self):
+    def test_individuals_ogrn(self, faker, num_samples):
         max_year = datetime.now().year - 2000
-
-        for i in range(self.num_sample_runs):
-            ogrn = self.fake.individuals_ogrn()
-
+        for _ in range(num_samples):
+            ogrn = faker.individuals_ogrn()
             assert len(ogrn) == 15
             assert ogrn[0] == '3'
             assert 1 <= int(ogrn[1:3]) <= max_year
             assert 1 <= int(ogrn[3:5]) <= 92
             assert int(ogrn[:-1]) % 13 % 10 == int(ogrn[-1])
 
-    def test_kpp(self):
-        for i in range(self.num_sample_runs):
-            kpp = self.fake.kpp()
-
+    def test_kpp(self, faker, num_samples):
+        for _ in range(num_samples):
+            kpp = faker.kpp()
             assert len(kpp) == 9
             assert 1 <= int(kpp[0:2]) <= 92
             assert int(kpp[2:4]) > 0
             assert kpp[4:6] in ('01', '43', '44', '45')
 
-    def test_company_prefix(self):
-        prefixes = RuProvider.company_prefixes
-        for i in range(self.num_sample_runs):
-            prefix = self.fake.company_prefix()
+    def test_company_prefix(self, faker, num_samples):
+        for _ in range(num_samples):
+            prefix = faker.company_prefix()
             assert isinstance(prefix, str)
-            assert prefix in prefixes
+            assert prefix in RuRuCompanyProvider.company_prefixes
 
-    def test_company_suffix(self):
-        suffixes = RuProvider.company_suffixes
-        for i in range(self.num_sample_runs):
-            suffix = self.fake.company_suffix()
+    def test_company_suffix(self, faker, num_samples):
+        for _ in range(num_samples):
+            suffix = faker.company_suffix()
             assert isinstance(suffix, str)
-            assert suffix in suffixes
+            assert suffix in RuRuCompanyProvider.company_suffixes
 
-    def test_large_companies(self):
-        companies = RuProvider.large_companies
-        for i in range(self.num_sample_runs):
-            company = self.fake.large_company()
+    def test_large_companies(self, faker, num_samples):
+        for _ in range(num_samples):
+            company = faker.large_company()
             assert isinstance(company, str)
-            assert company in companies
+            assert company in RuRuCompanyProvider.large_companies
 
-    def test_catchphrase(self):
-        for i in range(self.num_sample_runs):
-            catchphrase = self.fake.catch_phrase()
+    def test_catchphrase(self, faker, num_samples):
+        for _ in range(num_samples):
+            catchphrase = faker.catch_phrase()
             assert isinstance(catchphrase, str)
             assert ' и ' in catchphrase
 
-    def test_bs(self):
-        for i in range(self.num_sample_runs):
-            bs = self.fake.bs()
+    def test_bs(self, faker, num_samples):
+        for _ in range(num_samples):
+            bs = faker.bs()
             bs_words = bs.split()
             assert isinstance(bs, str)
-            assert bs_words[0] in RuProvider.bsWords[0]
+            assert bs_words[0] in RuRuCompanyProvider.bsWords[0]
diff --git a/tests/providers/test_credit_card.py b/tests/providers/test_credit_card.py
index afd925df..11b3df83 100644
--- a/tests/providers/test_credit_card.py
+++ b/tests/providers/test_credit_card.py
@@ -1,104 +1,127 @@
 import re
-import unittest
-
-from faker import Faker
-from faker.providers.bank.ru_RU import Provider as RuBank
-
-
-class TestCreditCardProvider(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker(locale='en_US')
-        Faker.seed(0)
-        self.provider = self.fake.provider('faker.providers.credit_card')
-        self.mastercard_pattern = r'^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$'
-        self.visa_pattern = r'^4[0-9]{12}([0-9]{3}){0,2}$'
-        self.discover_pattern = r'^6(?:011|5[0-9]{2})[0-9]{12}$'
-        self.diners_club_pattern = r'^3(?:0[0-5]|[68][0-9])[0-9]{11}$'
-        self.jcb_pattern = r'^(?:2131|1800|35\d{3})\d{11}$'
-
-    def test_mastercard(self):
-        for prefix in self.provider.prefix_mastercard:
-            number = self.provider._generate_number(prefix, 16)
-            assert re.match(self.mastercard_pattern, number)
-
-    def test_visa13(self):
-        for prefix in self.provider.prefix_visa:
-            number = self.provider._generate_number(prefix, 13)
-            assert re.match(self.visa_pattern, number)
-
-    def test_visa16(self):
-        for prefix in self.provider.prefix_visa:
-            number = self.provider._generate_number(prefix, 16)
-            assert re.match(self.visa_pattern, number)
-
-    def test_visa19(self):
-        for prefix in self.provider.prefix_visa:
-            number = self.provider._generate_number(prefix, 19)
-            assert re.match(self.visa_pattern, number)
-
-    def test_discover(self):
-        for prefix in self.provider.prefix_discover:
-            number = self.provider._generate_number(prefix, 16)
-            assert re.match(self.discover_pattern, number)
-
-    def test_diners_club(self):
-        for prefix in self.provider.prefix_diners:
-            number = self.provider._generate_number(prefix, 14)
-            assert re.match(self.diners_club_pattern, number)
-
-    def test_jcb16(self):
-        for prefix in self.provider.prefix_jcb16:
-            number = self.provider._generate_number(prefix, 16)
-            assert re.match(self.jcb_pattern, number)
-
-    def test_jcb15(self):
-        for prefix in self.provider.prefix_jcb15:
-            number = self.provider._generate_number(prefix, 15)
-            assert re.match(self.jcb_pattern, number)
-
-
-class TestRuRu(unittest.TestCase):
-    """ Tests credit card in the ru_RU locale """
-
-    def setUp(self):
-        self.fake = Faker('ru_RU')
-        Faker.seed(0)
-        self.visa_pattern = r'^4[0-9]{15}$'
-        self.mastercard_pattern = r'^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$'
-        self.mir_pattern = r'^220[0-4][0-9]{12}$'
-        self.maestro_pattern = r'^50|5[6-9]|6[0-9][0-9]{14}$'
-        self.amex_pattern = r'^3[4|7][0-9]{13}$'
-        self.unionpay_pattern = r'^62|81[0-9]{14}$'
-
-    def test_visa(self):
-        number = self.fake.credit_card_number('visa')
-        assert re.match(self.visa_pattern, number)
-
-    def test_mastercard(self):
-        number = self.fake.credit_card_number('mastercard')
-        assert re.match(self.mastercard_pattern, number)
-
-    def test_mir(self):
-        number = self.fake.credit_card_number('mir')
-        assert re.match(self.mir_pattern, number)
-
-    def test_maestro(self):
-        number = self.fake.credit_card_number('maestro')
-        assert re.match(self.maestro_pattern, number)
-
-    def test_amex(self):
-        number = self.fake.credit_card_number('amex')
-        assert re.match(self.amex_pattern, number)
-
-    def test_unionpay(self):
-        number = self.fake.credit_card_number('unionpay')
-        assert re.match(self.unionpay_pattern, number)
-
-    def test_owner(self):
-        card_data = self.fake.credit_card_full().split('\n')
-        assert re.match('[A-Za-z]+', card_data[1])
-
-    def test_issuer(self):
-        card_data = self.fake.credit_card_full().split('\n')
-        assert card_data[4] in RuBank.banks
+
+from faker.providers.bank.ru_RU import Provider as RuRuBankProvider
+from faker.providers.credit_card import Provider as CreditCardProvider
+
+
+class TestCreditCardProvider:
+    """Test credit card provider methods"""
+    mastercard_pattern = re.compile(
+        r'(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}',
+    )
+    visa_pattern = re.compile(r'4[0-9]{12}([0-9]{3}){0,2}')
+    discover_pattern = re.compile(r'6(?:011|5[0-9]{2})[0-9]{12}')
+    diners_club_pattern = re.compile(r'3(?:0[0-5]|[68][0-9])[0-9]{11}')
+    jcb_pattern = re.compile(r'(?:2131|1800|35\d{3})\d{11}')
+
+    def test_mastercard(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_mastercard:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 16)
+                assert len(number) == 16
+                assert self.mastercard_pattern.fullmatch(number)
+
+    def test_visa13(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_visa:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 13)
+                assert len(number) == 13
+                assert self.visa_pattern.fullmatch(number)
+
+    def test_visa16(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_visa:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 16)
+                assert len(number) == 16
+                assert self.visa_pattern.fullmatch(number)
+
+    def test_visa19(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_visa:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 19)
+                assert len(number) == 19
+                assert self.visa_pattern.fullmatch(number)
+
+    def test_discover(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_discover:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 16)
+                assert len(number) == 16
+                assert self.discover_pattern.fullmatch(number)
+
+    def test_diners_club(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_diners:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 14)
+                assert len(number) == 14
+                assert self.diners_club_pattern.fullmatch(number)
+
+    def test_jcb16(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_jcb16:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 16)
+                assert len(number) == 16
+                assert self.jcb_pattern.fullmatch(number)
+
+    def test_jcb15(self, faker, num_samples):
+        provider = CreditCardProvider(faker)
+        for prefix in provider.prefix_jcb15:
+            for _ in range(num_samples):
+                number = provider._generate_number(prefix, 15)
+                assert len(number) == 15
+                assert self.jcb_pattern.fullmatch(number)
+
+
+class TestRuRu:
+    """Test ru_RU credit card provider methods"""
+    visa_pattern = re.compile(r'4[0-9]{15}')
+    mastercard_pattern = re.compile(
+        r'(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}',
+    )
+    mir_pattern = re.compile(r'220[0-4][0-9]{12}')
+    maestro_pattern = re.compile(r'(?:50|5[6-9]|6[0-9])[0-9]{14}')
+    amex_pattern = re.compile(r'3[4|7][0-9]{13}')
+    unionpay_pattern = re.compile(r'(?:62|81)[0-9]{14}')
+
+    def test_visa(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('visa')
+            assert self.visa_pattern.fullmatch(number)
+
+    def test_mastercard(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('mastercard')
+            assert self.mastercard_pattern.fullmatch(number)
+
+    def test_mir(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('mir')
+            assert self.mir_pattern.fullmatch(number)
+
+    def test_maestro(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('maestro')
+            assert self.maestro_pattern.fullmatch(number)
+
+    def test_amex(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('amex')
+            assert self.amex_pattern.fullmatch(number)
+
+    def test_unionpay(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.credit_card_number('unionpay')
+            assert self.unionpay_pattern.fullmatch(number)
+
+    def test_credit_card_full(self, faker, num_samples):
+        for _ in range(num_samples):
+            card_data = faker.credit_card_full().split('\n')
+            assert re.match('[A-Za-z]+', card_data[1])
+            assert card_data[4] in RuRuBankProvider.banks
diff --git a/tests/providers/test_misc.py b/tests/providers/test_misc.py
index f81e7136..7822eb54 100644
--- a/tests/providers/test_misc.py
+++ b/tests/providers/test_misc.py
@@ -2,14 +2,36 @@ import csv
 import io
 import itertools
 import json
+import re
 import tarfile
-import unittest
 import uuid
 import zipfile
 
 from unittest.mock import patch
 
+import pytest
+
 from faker import Faker
+from faker.contrib.pytest.plugin import DEFAULT_LOCALE, DEFAULT_SEED
+
+
+@pytest.fixture(scope='class')
+def _class_faker_with_foobar():
+    _fake = Faker(locale=DEFAULT_LOCALE)
+    _fake.add_provider(_FooBarProvider())
+    _fake.set_arguments('argument_group', 'param', 'Baz')
+    _fake.set_arguments('double', 'multi', 2)
+    return _fake
+
+
+@pytest.fixture()
+def faker_with_foobar(request):
+    fake = request.getfixturevalue('_class_faker_with_foobar')
+    seed = DEFAULT_SEED
+    if 'faker_seed' in request.fixturenames:
+        seed = request.getfixturevalue('faker_seed')
+    fake.seed_instance(seed=seed)
+    return fake
 
 
 class _FooBarProvider:
@@ -24,81 +46,73 @@ class _FooBarProvider:
         return 1.1 * multi
 
 
-class TestMisc(unittest.TestCase):
-    """Tests miscellaneous generators"""
-    def setUp(self):
-        self.fake = Faker()
-        self.fake.add_provider(_FooBarProvider())
-        self.fake.set_arguments('argument_group', 'param', 'Baz')
-        self.fake.set_arguments('double', 'multi', 2)
-        Faker.seed(0)
-
-    def test_uuid4_str(self):
-        uuid4 = self.fake.uuid4()
-        assert uuid4
-        assert isinstance(uuid4, str)
-
-    def test_uuid4_int(self):
-        uuid4 = self.fake.uuid4(cast_to=int)
-        assert uuid4
-        assert isinstance(uuid4, int)
-
-    def test_uuid4_uuid_object(self):
-        uuid4 = self.fake.uuid4(cast_to=None)
-        assert uuid4
-        assert isinstance(uuid4, uuid.UUID)
-
-    def test_uuid4_seedability(self):
-        for _ in range(10):
-            random_seed = self.fake.random_int()
-            baseline_fake = Faker()
-            Faker.seed(random_seed)
-            expected_uuids = [baseline_fake.uuid4() for i in range(1000)]
-
-            new_fake = Faker()
-            Faker.seed(random_seed)
-            new_uuids = [new_fake.uuid4() for i in range(1000)]
+class TestMiscProvider:
+    """Test miscellaneous provider methods"""
+    num_samples = 10
+
+    def test_uuid4_str(self, faker, num_samples):
+        pattern = re.compile(r'[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}')
+        for _ in range(num_samples):
+            assert pattern.fullmatch(faker.uuid4())
+
+    def test_uuid4_int(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert isinstance(faker.uuid4(cast_to=int), int)
+
+    def test_uuid4_uuid_object(self, faker, num_samples):
+        for _ in range(num_samples):
+            uuid4 = faker.uuid4(cast_to=None)
+            assert isinstance(uuid4, uuid.UUID)
+            assert uuid4.version == 4
+
+    def test_uuid4_seedability(self, faker, num_samples):
+        for _ in range(num_samples):
+            random_seed = faker.random_int()
+            faker.seed_instance(random_seed)
+            expected_uuids = [faker.uuid4() for _ in range(100)]
+            faker.seed_instance(random_seed)
+            new_uuids = [faker.uuid4() for _ in range(100)]
             assert new_uuids == expected_uuids
 
-    def test_zip_invalid_file(self):
-        with self.assertRaises(ValueError):
-            self.fake.zip(num_files='1')
+    def test_zip_invalid_file(self, faker):
+        with pytest.raises(ValueError):
+            faker.zip(num_files='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.zip(num_files=0)
+        with pytest.raises(ValueError):
+            faker.zip(num_files=0)
 
-        with self.assertRaises(ValueError):
-            self.fake.zip(min_file_size='1')
+        with pytest.raises(ValueError):
+            faker.zip(min_file_size='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.zip(min_file_size=0)
+        with pytest.raises(ValueError):
+            faker.zip(min_file_size=0)
 
-        with self.assertRaises(ValueError):
-            self.fake.zip(uncompressed_size='1')
+        with pytest.raises(ValueError):
+            faker.zip(uncompressed_size='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.zip(uncompressed_size=0)
+        with pytest.raises(ValueError):
+            faker.zip(uncompressed_size=0)
 
-    def test_zip_one_byte_undersized(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
+    def test_zip_one_byte_undersized(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
             uncompressed_size = num_files * min_file_size - 1
 
             # Will always fail because of bad size requirements
-            with self.assertRaises(AssertionError):
-                self.fake.zip(
+            with pytest.raises(AssertionError):
+                faker.zip(
                     uncompressed_size=uncompressed_size, num_files=num_files,
                     min_file_size=min_file_size,
                 )
 
-    def test_zip_exact_minimum_size(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
+    def test_zip_exact_minimum_size(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
             uncompressed_size = num_files * min_file_size
 
-            zip_bytes = self.fake.zip(
+            zip_bytes = faker.zip(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size,
             )
@@ -120,14 +134,14 @@ class TestMisc(unittest.TestCase):
                 # The file sizes should sum up to the specified uncompressed size
                 assert total_size == uncompressed_size
 
-    def test_zip_over_minimum_size(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
-            expected_extra_bytes = self.fake.random.randint(1, 1024 * 1024)
+    def test_zip_over_minimum_size(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
+            expected_extra_bytes = faker.random.randint(1, 1024 * 1024)
             uncompressed_size = num_files * min_file_size + expected_extra_bytes
 
-            zip_bytes = self.fake.zip(
+            zip_bytes = faker.zip(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size,
             )
@@ -154,7 +168,7 @@ class TestMisc(unittest.TestCase):
                 assert total_size == uncompressed_size
                 assert extra_bytes == expected_extra_bytes
 
-    def test_zip_compression_py3(self):
+    def test_zip_compression_py3(self, faker):
         num_files = 10
         min_file_size = 512
         uncompressed_size = 50 * 1024
@@ -169,7 +183,7 @@ class TestMisc(unittest.TestCase):
             (None, zipfile.ZIP_STORED),
         ]
         for compression, compress_type in compression_mapping:
-            zip_bytes = self.fake.zip(
+            zip_bytes = faker.zip(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size, compression=compression,
             )
@@ -182,45 +196,45 @@ class TestMisc(unittest.TestCase):
                 for info in zip_handle.infolist():
                     assert info.compress_type == compress_type
 
-    def test_tar_invalid_file(self):
-        with self.assertRaises(ValueError):
-            self.fake.tar(num_files='1')
+    def test_tar_invalid_file(self, faker):
+        with pytest.raises(ValueError):
+            faker.tar(num_files='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.tar(num_files=0)
+        with pytest.raises(ValueError):
+            faker.tar(num_files=0)
 
-        with self.assertRaises(ValueError):
-            self.fake.tar(min_file_size='1')
+        with pytest.raises(ValueError):
+            faker.tar(min_file_size='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.tar(min_file_size=0)
+        with pytest.raises(ValueError):
+            faker.tar(min_file_size=0)
 
-        with self.assertRaises(ValueError):
-            self.fake.tar(uncompressed_size='1')
+        with pytest.raises(ValueError):
+            faker.tar(uncompressed_size='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.tar(uncompressed_size=0)
+        with pytest.raises(ValueError):
+            faker.tar(uncompressed_size=0)
 
-    def test_tar_one_byte_undersized(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
+    def test_tar_one_byte_undersized(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
             uncompressed_size = num_files * min_file_size - 1
 
             # Will always fail because of conflicting size requirements
-            with self.assertRaises(AssertionError):
-                self.fake.tar(
+            with pytest.raises(AssertionError):
+                faker.tar(
                     uncompressed_size=uncompressed_size, num_files=num_files,
                     min_file_size=min_file_size,
                 )
 
-    def test_tar_exact_minimum_size(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
+    def test_tar_exact_minimum_size(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
             uncompressed_size = num_files * min_file_size
 
-            tar_bytes = self.fake.tar(
+            tar_bytes = faker.tar(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size,
             )
@@ -239,14 +253,14 @@ class TestMisc(unittest.TestCase):
                 # The file sizes should sum up to the specified uncompressed size
                 assert total_size == uncompressed_size
 
-    def test_tar_over_minimum_size(self):
-        for _ in range(10):
-            num_files = self.fake.random.randint(1, 100)
-            min_file_size = self.fake.random.randint(1, 1024)
-            expected_extra_bytes = self.fake.random.randint(1, 1024 * 1024)
+    def test_tar_over_minimum_size(self, faker, num_samples):
+        for _ in range(num_samples):
+            num_files = faker.random.randint(1, 100)
+            min_file_size = faker.random.randint(1, 1024)
+            expected_extra_bytes = faker.random.randint(1, 1024 * 1024)
             uncompressed_size = num_files * min_file_size + expected_extra_bytes
 
-            tar_bytes = self.fake.tar(
+            tar_bytes = faker.tar(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size,
             )
@@ -270,7 +284,7 @@ class TestMisc(unittest.TestCase):
                 assert total_size == uncompressed_size
                 assert extra_bytes == expected_extra_bytes
 
-    def test_tar_compression_py3(self):
+    def test_tar_compression_py3(self, faker):
         num_files = 25
         min_file_size = 512
         uncompressed_size = 50 * 1024
@@ -285,7 +299,7 @@ class TestMisc(unittest.TestCase):
         ]
 
         for compression, read_mode in compression_mapping:
-            tar_bytes = self.fake.tar(
+            tar_bytes = faker.tar(
                 uncompressed_size=uncompressed_size, num_files=num_files,
                 min_file_size=min_file_size, compression=compression,
             )
@@ -295,27 +309,27 @@ class TestMisc(unittest.TestCase):
                 members = tar_handle.getmembers()
                 assert len(members) == num_files
 
-    def test_dsv_with_invalid_values(self):
-        with self.assertRaises(ValueError):
-            self.fake.dsv(num_rows='1')
+    def test_dsv_with_invalid_values(self, faker):
+        with pytest.raises(ValueError):
+            faker.dsv(num_rows='1')
 
-        with self.assertRaises(ValueError):
-            self.fake.dsv(num_rows=0)
+        with pytest.raises(ValueError):
+            faker.dsv(num_rows=0)
 
-        with self.assertRaises(TypeError):
-            self.fake.dsv(header=None, data_columns=1)
+        with pytest.raises(TypeError):
+            faker.dsv(header=None, data_columns=1)
 
-        with self.assertRaises(TypeError):
-            self.fake.dsv(header=1, data_columns=['???'])
+        with pytest.raises(TypeError):
+            faker.dsv(header=1, data_columns=['???'])
 
-        with self.assertRaises(ValueError):
-            self.fake.dsv(header=['Column 1', 'Column 2'], data_columns=['???'])
+        with pytest.raises(ValueError):
+            faker.dsv(header=['Column 1', 'Column 2'], data_columns=['???'])
 
-    def test_dsv_no_header(self):
+    def test_dsv_no_header(self, faker, num_samples):
         data_columns = ['????', '?????']
-        for _ in range(10):
-            num_rows = self.fake.random.randint(1, 1000)
-            dsv = self.fake.dsv(header=None, data_columns=data_columns, num_rows=num_rows)
+        for _ in range(num_samples):
+            num_rows = faker.random.randint(1, 1000)
+            dsv = faker.dsv(header=None, data_columns=data_columns, num_rows=num_rows)
             reader = csv.reader(io.StringIO(dsv), dialect='faker-csv')
 
             # Verify each row has correct number of columns
@@ -325,12 +339,12 @@ class TestMisc(unittest.TestCase):
             # Verify correct number of lines read
             assert reader.line_num == num_rows
 
-    def test_dsv_with_valid_header(self):
+    def test_dsv_with_valid_header(self, faker, num_samples):
         header = ['Column 1', 'Column 2']
         data_columns = ['????', '?????']
-        for _ in range(10):
-            num_rows = self.fake.random.randint(1, 1000)
-            dsv = self.fake.dsv(header=header, data_columns=data_columns, num_rows=num_rows)
+        for _ in range(num_samples):
+            num_rows = faker.random.randint(1, 1000)
+            dsv = faker.dsv(header=header, data_columns=data_columns, num_rows=num_rows)
             reader = csv.reader(io.StringIO(dsv), dialect='faker-csv')
 
             # Verify each row has correct number of columns
@@ -340,12 +354,12 @@ class TestMisc(unittest.TestCase):
             # Verify correct number of lines read (additional header row)
             assert reader.line_num == num_rows + 1
 
-    def test_dsv_with_row_ids(self):
+    def test_dsv_with_row_ids(self, faker, num_samples):
         data_columns = ['????', '?????']
-        for _ in range(10):
+        for _ in range(num_samples):
             counter = 0
-            num_rows = self.fake.random.randint(1, 1000)
-            dsv = self.fake.dsv(
+            num_rows = faker.random.randint(1, 1000)
+            dsv = faker.dsv(
                 header=None, data_columns=data_columns,
                 num_rows=num_rows, include_row_ids=True,
             )
@@ -361,12 +375,12 @@ class TestMisc(unittest.TestCase):
             # Verify correct number of lines read
             assert reader.line_num == num_rows
 
-    def test_dsv_data_columns(self):
+    def test_dsv_data_columns(self, faker):
         num_rows = 10
         data_columns = ['{{name}}', '#??-####', '{{address}}', '{{phone_number}}']
-        with patch.object(self.fake['en_US'], 'pystr_format') as mock_pystr_format:
+        with patch.object(faker['en_US'], 'pystr_format') as mock_pystr_format:
             mock_pystr_format.assert_not_called()
-            self.fake.dsv(data_columns=data_columns, num_rows=num_rows)
+            faker.dsv(data_columns=data_columns, num_rows=num_rows)
 
             # pystr_format will be called for each data column and each row
             calls = mock_pystr_format.call_args_list
@@ -378,7 +392,7 @@ class TestMisc(unittest.TestCase):
                 assert args[0] == next(column_cycle)
                 assert kwargs == {}
 
-    def test_dsv_csvwriter_kwargs(self):
+    def test_dsv_csvwriter_kwargs(self, faker):
         data_keys = ['header', 'data_columns', 'num_rows', 'include_row_ids']
         test_kwargs = {
             'dialect': 'excel',
@@ -391,7 +405,7 @@ class TestMisc(unittest.TestCase):
         }
         with patch('faker.providers.misc.csv.writer') as mock_writer:
             mock_writer.assert_not_called()
-            self.fake.dsv(**test_kwargs)
+            faker.dsv(**test_kwargs)
             assert mock_writer.call_count == 1
 
             # Remove all data generation kwargs
@@ -402,7 +416,7 @@ class TestMisc(unittest.TestCase):
             for args, kwargs in mock_writer.call_args_list:
                 assert kwargs == test_kwargs
 
-    def test_csv_helper_method(self):
+    def test_csv_helper_method(self, faker):
         kwargs = {
             'header': ['Column 1', 'Column 2'],
             'data_columns': ['????', '?????'],
@@ -411,11 +425,11 @@ class TestMisc(unittest.TestCase):
         }
         with patch('faker.providers.misc.Provider.dsv') as mock_dsv:
             mock_dsv.assert_not_called()
-            self.fake.csv(**kwargs)
+            faker.csv(**kwargs)
             kwargs['delimiter'] = ','
             mock_dsv.assert_called_once_with(**kwargs)
 
-    def test_tsv_helper_method(self):
+    def test_tsv_helper_method(self, faker):
         kwargs = {
             'header': ['Column 1', 'Column 2'],
             'data_columns': ['????', '?????'],
@@ -424,11 +438,11 @@ class TestMisc(unittest.TestCase):
         }
         with patch('faker.providers.misc.Provider.dsv') as mock_dsv:
             mock_dsv.assert_not_called()
-            self.fake.tsv(**kwargs)
+            faker.tsv(**kwargs)
             kwargs['delimiter'] = '\t'
             mock_dsv.assert_called_once_with(**kwargs)
 
-    def test_psv_helper_method(self):
+    def test_psv_helper_method(self, faker):
         kwargs = {
             'header': ['Column 1', 'Column 2'],
             'data_columns': ['????', '?????'],
@@ -437,11 +451,11 @@ class TestMisc(unittest.TestCase):
         }
         with patch('faker.providers.misc.Provider.dsv') as mock_dsv:
             mock_dsv.assert_not_called()
-            self.fake.psv(**kwargs)
+            faker.psv(**kwargs)
             kwargs['delimiter'] = '|'
             mock_dsv.assert_called_once_with(**kwargs)
 
-    def test_json_with_arguments(self):
+    def test_json_with_arguments(self, faker_with_foobar):
         kwargs = {
             'data_columns': [
                 ('item1', '{{ foo_bar:argument_group }}'),
@@ -449,21 +463,21 @@ class TestMisc(unittest.TestCase):
             ],
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data.get('item1') == 'FooBarBaz'
         assert json_data.get('item2') == 'FooBarBAZ'
 
-    def test_json_multiple_rows(self):
+    def test_json_multiple_rows(self, faker_with_foobar):
         kwargs = {
             'data_columns': {'item': 'foo_bar'},
             'num_rows': 2,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert isinstance(json_data, list) and len(json_data) == 2
 
-    def test_json_passthrough_int_float(self):
+    def test_json_passthrough_int_float(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'item1': 1,
@@ -471,12 +485,12 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['item1'] == 1
         assert json_data['item2'] == 1.0
 
-    def test_json_type_integrity_int(self):
+    def test_json_type_integrity_int(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'item1': 'test_integer',
@@ -484,11 +498,11 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
         assert isinstance(json_data['item1'], int)
         assert json_data['item2'] == 2
 
-    def test_json_type_integrity_float(self):
+    def test_json_type_integrity_float(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'item1': 'test_float',
@@ -496,29 +510,29 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
         assert isinstance(json_data['item1'], float)
         assert json_data['item2'] == 2.2
 
-    def test_json_invalid_data_columns(self):
+    def test_json_invalid_data_columns(self, faker_with_foobar):
         kwargs = {
             'data_columns': (('item', 'foo_bar'),),
             'num_rows': 1,
         }
-        with self.assertRaises(TypeError) as excinfo:
-            json.loads(self.fake.json(**kwargs))
-        assert str(excinfo.exception) == 'Invalid data_columns type. Must be a dictionary or list'
+        with pytest.raises(TypeError) as excinfo:
+            json.loads(faker_with_foobar.json(**kwargs))
+        assert str(excinfo.value) == 'Invalid data_columns type. Must be a dictionary or list'
 
-    def test_json_list_format_invalid_arguments_type(self):
+    def test_json_list_format_invalid_arguments_type(self, faker_with_foobar):
         kwargs = {
             'data_columns': [('item', 'foo_bar', ['wrong'])],
             'num_rows': 1,
         }
-        with self.assertRaises(TypeError) as excinfo:
-            self.fake.json(**kwargs)
-        assert str(excinfo.exception) == 'Invalid arguments type. Must be a dictionary'
+        with pytest.raises(TypeError) as excinfo:
+            faker_with_foobar.json(**kwargs)
+        assert str(excinfo.value) == 'Invalid arguments type. Must be a dictionary'
 
-    def test_json_list_format_nested_list_of_values(self):
+    def test_json_list_format_nested_list_of_values(self, faker_with_foobar):
         kwargs = {
             'data_columns': [
                 (
@@ -530,12 +544,12 @@ class TestMisc(unittest.TestCase):
             ],
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['list'][0] == 'FooBars'
         assert json_data['list'][1] == 'FooBar'
 
-    def test_json_list_format_nested_list_of_objects(self):
+    def test_json_list_format_nested_list_of_objects(self, faker_with_foobar):
         kwargs = {
             'data_columns': [
                 (
@@ -547,12 +561,12 @@ class TestMisc(unittest.TestCase):
             ],
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['list'][0]['item'] == 'FooBars'
         assert json_data['list'][1]['item'] == 'FooBar'
 
-    def test_json_list_format_nested_objects(self):
+    def test_json_list_format_nested_objects(self, faker_with_foobar):
         kwargs = {
             'data_columns': [
                 (
@@ -564,12 +578,12 @@ class TestMisc(unittest.TestCase):
             ],
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['dict']['item1'] == 'FooBars'
         assert json_data['dict']['item2'] == 'FooBar'
 
-    def test_json_dict_format_nested_list_of_values(self):
+    def test_json_dict_format_nested_list_of_values(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'list': [
@@ -579,12 +593,12 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['list'][0] == 'FooBars'
         assert json_data['list'][1] == 'FooBar'
 
-    def test_json_dict_format_nested_list_of_objects(self):
+    def test_json_dict_format_nested_list_of_objects(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'list': [
@@ -594,12 +608,12 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['list'][0]['item'] == 'FooBars'
         assert json_data['list'][1]['item'] == 'FooBar'
 
-    def test_json_dict_format_nested_objects(self):
+    def test_json_dict_format_nested_objects(self, faker_with_foobar):
         kwargs = {
             'data_columns': {
                 'dict': {
@@ -609,12 +623,12 @@ class TestMisc(unittest.TestCase):
             },
             'num_rows': 1,
         }
-        json_data = json.loads(self.fake.json(**kwargs))
+        json_data = json.loads(faker_with_foobar.json(**kwargs))
 
         assert json_data['dict']['item1'] == 'FooBars'
         assert json_data['dict']['item2'] == 'FooBar'
 
-    def test_fixed_width_with_arguments(self):
+    def test_fixed_width_with_arguments(self, faker_with_foobar):
         kwargs = {
             'data_columns': [
                 (9, '{{ foo_bar:argument_group }}'),
@@ -622,18 +636,18 @@ class TestMisc(unittest.TestCase):
             ],
             'num_rows': 2,
         }
-        fixed_width_string = self.fake.fixed_width(**kwargs)
+        fixed_width_string = faker_with_foobar.fixed_width(**kwargs)
 
         for row in fixed_width_string.split('\n'):
             assert len(row) == 18
             assert row[0:9].strip() == 'FooBarBaz'
             assert row[9:18].strip() == 'FooBarBAR'
 
-    def test_fixed_width_invalid_arguments_type(self):
+    def test_fixed_width_invalid_arguments_type(self, faker_with_foobar):
         kwargs = {
             'data_columns': [(9, 'foo_bar', ['wrong'])],
             'num_rows': 1,
         }
-        with self.assertRaises(TypeError) as excinfo:
-            self.fake.fixed_width(**kwargs)
-        assert str(excinfo.exception) == 'Invalid arguments type. Must be a dictionary'
+        with pytest.raises(TypeError) as excinfo:
+            faker_with_foobar.fixed_width(**kwargs)
+        assert str(excinfo.value) == 'Invalid arguments type. Must be a dictionary'
diff --git a/tests/providers/test_phone_number.py b/tests/providers/test_phone_number.py
index 49fd5a6f..3ff20508 100644
--- a/tests/providers/test_phone_number.py
+++ b/tests/providers/test_phone_number.py
@@ -1,218 +1,178 @@
 import re
-import unittest
 
-from faker import Faker
+from faker.providers.phone_number import Provider as PhoneNumberProvider
+from faker.providers.phone_number.en_PH import Provider as EnPhPhoneNumberProvider
 
 
-class TestPhoneNumber(unittest.TestCase):
-    """ Tests phone_number in the ja_JP locale """
+class TestPhoneNumber:
+    """Test phone number provider methods"""
 
-    def setUp(self):
-        self.fake = Faker()
-        Faker.seed(0)
+    def test_country_calling_code(self, faker, num_samples):
+        for _ in range(num_samples):
+            cc = faker.country_calling_code()
+            assert cc in PhoneNumberProvider.country_calling_codes
 
-    def test_phone_number(self):
-        pn = self.fake.phone_number()
+    def test_msisdn(self, faker, num_samples):
+        for _ in range(num_samples):
+            msisdn = faker.msisdn()
+            assert isinstance(msisdn, str)
+            assert len(msisdn) == 13
+            assert msisdn.isdigit()
 
-        assert pn
-        assert isinstance(pn, str)
 
-    def test_country_calling_code(self):
-        cc = self.fake.country_calling_code()
+class TestJaJp:
+    """Test ja_JP phone number provider methods"""
 
-        assert cc
-        assert isinstance(cc, str)
-        assert cc.startswith('+')
+    def test_phone_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            pattern = re.compile(r'(?:0[789]0|\d{2})-\d{4}-\d{4}')
+            phone_number = faker.phone_number()
+            assert pattern.fullmatch(phone_number)
 
-    def test_msisdn(self):
-        msisdn = self.fake.msisdn()
 
-        assert msisdn is not None
-        assert isinstance(msisdn, str)
-        assert len(msisdn) == 13
-        assert msisdn.isdigit()
+class TestPtBr:
+    """Test pt_BR phone number provider methods"""
 
+    def test_phone_number(self, faker, num_samples):
+        pattern = re.compile(
+            r'(?:\+55 )?'
+            r'(?:[1-8]1|84|\((?:0[1-8]1|084)\))'
+            r' \d{4}[ -]\d{4}',
+        )
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert pattern.fullmatch(phone_number)
+
+    def test_msisdn(self, faker, num_samples):
+        pattern = re.compile(r'55(?:[1-8]19|849)\d{8}')
+        for _ in range(num_samples):
+            msisdn = faker.msisdn()
+            assert pattern.fullmatch(msisdn)
+
+    def test_cellphone(self, faker, num_samples):
+        pattern = re.compile(
+            r'(?:\+55 )?'
+            r'(?:\d{2}|\(0?\d{2}\))'
+            r' 9 ?\d{4}[ -]\d{4}',
+        )
+        for _ in range(num_samples):
+            cellphone = faker.cellphone_number()
+            assert pattern.fullmatch(cellphone)
+
+
+class TestHuHu:
+    """Test hu_HU phone number provider methods"""
+
+    def test_phone_number(self, faker, num_samples):
+        pattern = re.compile(
+            r'(?:'
+            r'\+36 \d{2} |'
+            r'\(06\)\d{2}/|'
+            r'\(\d{2}\)/|'
+            r'\d{2}/|'
+            r'06-\d{1,2}/'
+            r')\d{3}[- ]\d{4}',
+        )
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert isinstance(phone_number, str)
+            assert pattern.fullmatch(phone_number)
 
-class TestJa(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('ja')
-        Faker.seed(0)
-
-    def test_phone_number(self):
-        pn = self.fake.phone_number()
-        formats = ('070', '080', '090')
-
-        assert pn
-        assert isinstance(pn, str)
-        first, second, third = pn.split('-')
-        assert first
-        assert first.isdigit()
-        assert second
-        assert second.isdigit()
-        assert third
-        assert third.isdigit()
-        if len(first) == 2:
-            assert len(second) == 4
-            assert len(third) == 4
-        else:
-            assert len(first) == 3
-            assert len(second) == 4
-            assert len(third) == 4
-            assert first in formats
-
-
-class TestPtBr(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('pt_br')
-        Faker.seed(0)
-
-    def test_phone_number(self):
-        phone_number = self.fake.phone_number()
-        re.match(r"^[+]?([0-9]{2})?[ ]?[(]?[0]?\d{2}[)]?[ ]?[09]?[ ]?\d{4}[ -]?\d{4}$", phone_number)
-
-    def test_msisdn(self):
-        msisdn = self.fake.msisdn()
-        formats = ('5511', '5521', '5531', '5541', '5551', '5561', '5571', '5581', '5584')
-
-        assert msisdn is not None
-        assert isinstance(msisdn, str)
-        assert len(msisdn) == 13
-        assert msisdn.isdigit()
-        assert msisdn[0:4] in formats
-        re.match(r"^[5]{2}\d{2}[9]\d{8}$", msisdn)
-
-    def test_cellphone(self):
-        cellphone = self.fake.cellphone_number()
-        assert cellphone is not None
-        assert cellphone[0:3] == '+55'
-        re.match(r"^[+]?([0-9]{2})?[ ]?[(]?[0]?\d{2}[)]?[ ]?[09]?[ ]?\d{4}[ -]?\d{4}$", cellphone)
-
-
-class TestHuHU(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('hu_HU')
-        Faker.seed(0)
-
-    def test_phone_number(self):
-        phone_number = self.fake.phone_number()
-        re.match(r"[1-9]\d/\d{3} \d{4}", phone_number)
-
-
-class TestThTH(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('th_TH')
-        Faker.seed(0)
-
-    def test_phone_number_should_be_in_defined_format(self):
-        phone_number = self.fake.phone_number()
-
-        first, second, third = phone_number.split(' ')
-
-        formats = ('+66', '+668')
-        self.assertTrue(first in formats)
-
-        if len(first) == 3:
-            self.assertEqual(first, '+66')
-        elif len(first) == 4:
-            self.assertEqual(first, '+668')
-
-        self.assertEqual(len(second), 4)
-        self.assertEqual(len(third), 4)
-
-
-class TestHyAm(unittest.TestCase):
-    """ Tests phone_number in the hy_AM locale """
-
-    def setUp(self):
-        self.fake = Faker('hy_AM')
-        Faker.seed(0)
-
-    def test_phone_number(self):
-        pn = self.fake.phone_number()
-        assert isinstance(pn, str)
 
+class TestThTh:
+    """Test th_TH phone number provider methods"""
 
-class TestEnPh(unittest.TestCase):
-    num_sample_runs = 1000
+    def test_phone_number_should_be_in_defined_format(self, faker, num_samples):
+        pattern = re.compile(r'\+668? \d{4} \d{4}')
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert isinstance(phone_number, str)
+            assert pattern.fullmatch(phone_number)
 
-    def setUp(self):
-        self.mobile_number_pattern = re.compile(r'^(?:0|\+63)(\d+)-\d{3}-\d{4}$')
-        self.area2_landline_number_pattern = re.compile(r'^(?:0|\+63)2-(\d{4})-\d{4}')
-        self.non_area2_landline_number_pattern = re.compile(r'^(?:0|\+63)(\d{2})-(\d{3})-\d{4}')
-        self.setup_constants()
-        self.setup_faker()
 
-    def setup_faker(self):
-        self.fake = Faker('en_PH')
-        Faker.seed(0)
+class TestHyAm:
+    """Test hy_AM phone number provider methods"""
 
-    def setup_constants(self):
-        from faker.providers.phone_number.en_PH import Provider
-        self.globe_mobile_number_prefixes = Provider.globe_mobile_number_prefixes
-        self.smart_mobile_number_prefixes = Provider.smart_mobile_number_prefixes
-        self.sun_mobile_number_prefixes = Provider.sun_mobile_number_prefixes
-        self.mobile_number_prefixes = (
-            self.globe_mobile_number_prefixes + self.smart_mobile_number_prefixes + self.sun_mobile_number_prefixes
+    def test_phone_number(self, faker, num_samples):
+        pattern = re.compile(
+            r'(?:[23]\d{2}-|\([23]\d{2}\) |[23]\d{2}\.)\d{5}|'
+            r'(?:(?:10|9\d)-|\((?:10|9\d)\) |(?:10|9\d)\.)\d{6}',
+        )
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert isinstance(phone_number, str)
+            assert pattern.fullmatch(phone_number)
+
+
+class TestEnPh:
+    """Test en_PH phone number provider methods"""
+
+    @classmethod
+    def setup_class(cls):
+        cls.mobile_number_pattern = re.compile(r'^(?:0|\+63)(\d+)-\d{3}-\d{4}$')
+        cls.area2_landline_number_pattern = re.compile(r'^(?:0|\+63)2-(\d{4})-\d{4}')
+        cls.non_area2_landline_number_pattern = re.compile(r'^(?:0|\+63)(\d{2})-(\d{3})-\d{4}')
+        cls.globe_mobile_number_prefixes = EnPhPhoneNumberProvider.globe_mobile_number_prefixes
+        cls.smart_mobile_number_prefixes = EnPhPhoneNumberProvider.smart_mobile_number_prefixes
+        cls.sun_mobile_number_prefixes = EnPhPhoneNumberProvider.sun_mobile_number_prefixes
+        cls.mobile_number_prefixes = (
+            cls.globe_mobile_number_prefixes + cls.smart_mobile_number_prefixes + cls.sun_mobile_number_prefixes
         )
-        self.bayantel_landline_identifiers = Provider.bayantel_landline_identifiers
-        self.misc_landline_identifiers = Provider.misc_landline_identifiers
-        self.non_area2_landline_area_codes = Provider.non_area2_landline_area_codes
+        cls.bayantel_landline_identifiers = EnPhPhoneNumberProvider.bayantel_landline_identifiers
+        cls.misc_landline_identifiers = EnPhPhoneNumberProvider.misc_landline_identifiers
+        cls.non_area2_landline_area_codes = EnPhPhoneNumberProvider.non_area2_landline_area_codes
 
-    def test_PH_globe_mobile_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.globe_mobile_number()
+    def test_globe_mobile_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.globe_mobile_number()
             match = self.mobile_number_pattern.match(number)
             assert match and match.group(1) in self.globe_mobile_number_prefixes
 
-    def test_PH_smart_mobile_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.smart_mobile_number()
+    def test_smart_mobile_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.smart_mobile_number()
             match = self.mobile_number_pattern.match(number)
             assert match and match.group(1) in self.smart_mobile_number_prefixes
 
-    def test_PH_sun_mobile_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.sun_mobile_number()
+    def test_sun_mobile_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.sun_mobile_number()
             match = self.mobile_number_pattern.match(number)
             assert match and match.group(1) in self.sun_mobile_number_prefixes
 
-    def test_PH_mobile_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.mobile_number()
+    def test_mobile_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.mobile_number()
             match = self.mobile_number_pattern.match(number)
             assert match and match.group(1) in self.mobile_number_prefixes
 
-    def test_PH_globe_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.globe_area2_landline_number()
+    def test_globe_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.globe_area2_landline_number()
             match = self.area2_landline_number_pattern.match(number)
             assert match and match.group(1).startswith('7')
 
-    def test_PH_pldt_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.pldt_area2_landline_number()
+    def test_pldt_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.pldt_area2_landline_number()
             match = self.area2_landline_number_pattern.match(number)
             assert match and match.group(1).startswith('8')
 
-    def test_PH_bayantel_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.bayantel_area2_landline_number()
+    def test_bayantel_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.bayantel_area2_landline_number()
             match = self.area2_landline_number_pattern.match(number)
             assert match and match.group(1) in self.bayantel_landline_identifiers
 
-    def test_PH_misc_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.misc_area2_landline_number()
+    def test_misc_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.misc_area2_landline_number()
             match = self.area2_landline_number_pattern.match(number)
             assert match and match.group(1) in self.misc_landline_identifiers
 
-    def test_PH_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.area2_landline_number()
+    def test_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.area2_landline_number()
             match = self.area2_landline_number_pattern.match(number)
             assert match and any([
                 match.group(1).startswith('7'),
@@ -221,15 +181,15 @@ class TestEnPh(unittest.TestCase):
                 match.group(1) in self.misc_landline_identifiers,
             ])
 
-    def test_PH_non_area2_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.non_area2_landline_number()
+    def test_non_area2_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.non_area2_landline_number()
             match = self.non_area2_landline_number_pattern.match(number)
             assert match and match.group(1) in self.non_area2_landline_area_codes
 
-    def test_PH_landline_number(self):
-        for i in range(self.num_sample_runs):
-            number = self.fake.landline_number()
+    def test_landline_number(self, faker, num_samples):
+        for _ in range(num_samples):
+            number = faker.landline_number()
             area2_match = self.area2_landline_number_pattern.match(number)
             non_area2_match = self.non_area2_landline_number_pattern.match(number)
             assert area2_match or non_area2_match
@@ -245,36 +205,36 @@ class TestEnPh(unittest.TestCase):
 
 
 class TestFilPh(TestEnPh):
-
-    def setup_faker(self):
-        self.fake = Faker('fil_PH')
-        Faker.seed(0)
+    """Test fil_PH phone number provider methods"""
+    pass
 
 
 class TestTlPh(TestEnPh):
-
-    def setup_faker(self):
-        self.fake = Faker('tl_PH')
-        Faker.seed(0)
+    """Test tl_PH phone number provider methods"""
+    pass
 
 
-class TestTaIN(unittest.TestCase):
-
-    def setUp(self):
-        self.fake = Faker('ta_IN')
-        Faker.seed(0)
-
-    def test_phone_number(self):
-        phone_number = self.fake.phone_number()
-        re.match(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$", phone_number)
+class TestTaIn:
+    """Test ta_IN phone number provider methods"""
 
+    def test_phone_number(self, faker, num_samples):
+        pattern = re.compile(
+            r'\+91 \d{3} ?\d{7}|'
+            r'0\d{2}(-)?\d{2}(?(1)| ?)\d{6}',
+        )
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert pattern.fullmatch(phone_number)
 
-class TestEs_ES(unittest.TestCase):
 
-    def setUp(self):
-        self.fake = Faker('es_ES')
-        Faker.seed(0)
+class TestEsEs:
+    """Test es_ES phone number provider methods"""
 
-    def test_phone_number(self):
-        phone_number = self.fake.phone_number()
-        re.match(r"(\+34)?((6([0-9]*){8})|(7[1-4]+([0-9]*){7})|((8|9)[1-9]+([0-9]*){7}))$", phone_number)
+    def test_phone_number(self, faker, num_samples):
+        pattern = re.compile(
+            r'\+34 ?(?:7[0-4]|[689]\d)\d'
+            r'(?: \d{3} \d{3}|\d{6}| \d{2} \d{2} \d{2})',
+        )
+        for _ in range(num_samples):
+            phone_number = faker.phone_number()
+            assert pattern.fullmatch(phone_number)