Commit 4dc4c0b5 authored by Kipp Cannon's avatar Kipp Cannon

Merge branch 'force-python-library-in-testing' into 'master'

Hack import statement during testing to actually load python implementation

Closes #2

See merge request !21
parents dea8cd29 b403286d
Pipeline #46466 failed with stages
in 2 minutes and 15 seconds
......@@ -10,6 +10,30 @@ import verifyutils
import pkg_resources
#
# mock import statement to correctly load python implemention
#
try:
import builtins
except ImportError:
import __builtin__ as builtins
realimport = builtins.__import__
def no_c_library(name, globals=None, locals=None, fromlist=(), level=0):
if name == '__segments': # refuse to load C segments library
raise ImportError
return realimport(
name,
globals=globals,
locals=locals,
fromlist=fromlist,
level=level)
#
# How many times to repeat the algebraic tests
#
......@@ -512,7 +536,12 @@ class test_segmentlistdict(unittest.TestCase):
if __name__ == "__main__":
# first with the pure Python segments implementation
from ligo import segments
builtins.__import__ = no_c_library # refuse to load C library
try:
from ligo import segments
finally:
# reinstate original import
builtins.__import__ = realimport
verifyutils.segments = segments
suite = unittest.TestSuite()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment