From 4ee6ea2b0ce6c6f3b35c899be1c68827737f6c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Thu, 21 Jan 2021 16:46:21 +0100 Subject: [PATCH] Handle missing ukpostcodeparser gracefully in tests (#1383) 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. --- tests/providers/test_address.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py index efc9acf38a..369aa22249 100644 --- a/tests/providers/test_address.py +++ b/tests/providers/test_address.py @@ -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 @@ -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):