Skip to content

Commit d5e6eae

Browse files
authored
Add an explicit test for loading the yajl2_c extension (#99)
Following the discussion in #98, add an explicit test that verifies that the yajl2_c extension can be loaded successfully if it was built. If the extension module is not present, the test is skipped. Signed-off-by: Michał Górny <[email protected]>
1 parent ee7abe7 commit d5e6eae

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/test_misc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib.util
12
import unittest
23

34
from ijson import common, compat
@@ -16,6 +17,15 @@ def test_common_number_is_deprecated(self):
1617
self.assertEqual(len(warns), 1)
1718
self.assertEqual(DeprecationWarning, warns[0].category)
1819

20+
def test_yajl2_c_loadable(self):
21+
if compat.IS_PY2:
22+
self.skipTest("Test requires Python 3.4+")
23+
spec = importlib.util.find_spec("ijson.backends._yajl2")
24+
if spec is None:
25+
self.skipTest("yajl2_c is not built")
26+
importlib.util.module_from_spec(spec)
27+
28+
1929
class MainEntryPoints(object):
2030

2131
def _assert_invalid_type(self, routine, *args, **kwargs):

0 commit comments

Comments
 (0)