Skip to content

Commit

Permalink
Handle missing ukpostcodeparser gracefully in tests (joke2k#1383)
Browse files Browse the repository at this point in the history
Skip the single test relying on ukpostcodeparser if the relevant package
is not installed on the system.  There are users who don't really need
that particular function and appreciate the ability to test Faker
before installing it on their production systems.
  • Loading branch information
mgorny authored and fcurella committed Jun 2, 2021
1 parent b282b81 commit 4ee6ea2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/providers/test_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import pytest

from ukpostcodeparser.parser import parse_uk_postcode

from faker.providers.address.cs_CZ import Provider as CsCzAddressProvider
from faker.providers.address.da_DK import Provider as DaDkAddressProvider
from faker.providers.address.de_AT import Provider as DeAtAddressProvider
Expand Down Expand Up @@ -381,8 +379,9 @@ class TestEnGb:
"""Test en_GB address provider methods"""

def test_postcode(self, faker, num_samples):
ukpcp = pytest.importorskip('ukpostcodeparser.parser')
for _ in range(num_samples):
assert isinstance(parse_uk_postcode(faker.postcode()), tuple)
assert isinstance(ukpcp.parse_uk_postcode(faker.postcode()), tuple)

def test_county(self, faker, num_samples):
for _ in range(num_samples):
Expand Down

0 comments on commit 4ee6ea2

Please sign in to comment.