Skip to content

Commit 6b92980

Browse files
committed
Correct skipping of tests without extension
1 parent ba70a9d commit 6b92980

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/reader_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
import maxminddb
99

10+
try:
11+
import maxminddb.extension
12+
except ImportError:
13+
maxminddb.extension = None
14+
1015
from maxminddb import open_database, InvalidDatabaseError
1116
from maxminddb.compat import FileNotFoundError
1217
from maxminddb.const import MODE_MMAP_EXT, MODE_MMAP, MODE_FILE, MODE_MEMORY
@@ -315,14 +320,12 @@ def _check_ip_v6(self, reader, file_name):
315320
self.assertIsNone(reader.get(ip))
316321

317322

318-
try:
319-
import maxminddb.extension
323+
@unittest.skipUnless(maxminddb.extension, 'No C extension module found. Skipping tests')
324+
class TestExtensionReader(BaseTestReader, unittest.TestCase):
325+
mode = MODE_MMAP_EXT
320326

321-
class TestExtensionReader(BaseTestReader, unittest.TestCase):
322-
mode = MODE_MMAP_EXT
327+
if maxminddb.extension:
323328
readerClass = [maxminddb.extension.Reader]
324-
except:
325-
unittest.skip('No C extension module found. Skipping tests')
326329

327330

328331
class TestMMAPReader(BaseTestReader, unittest.TestCase):

0 commit comments

Comments
 (0)