From 81a43ae6c21edb2d613f09b75a0c32ed43532cfe Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Sun, 3 Dec 2023 14:59:32 +0000 Subject: [PATCH] Fix usage of setup.py test --- tests/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index cf971c99..5bbd8d67 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -27,13 +27,25 @@ #------------------------------------------------------------------------ def distutils_dir_name(dir_name): """Returns the name of a distutils build directory""" - f = "{dirname}.{platform}-{version[0]}.{version[1]}" + f = "{dirname}.{platform}-cpython-{version[0]}{version[1]}" return f.format(dirname=dir_name, platform=sysconfig.get_platform(), version=sys.version_info) +#------------------------------------------------------------------------ +# Ensure that build dir exists and prioritise this library in sys.path +#------------------------------------------------------------------------ build_dir = os.path.join("build", distutils_dir_name("lib")) -sys.path.insert(0, build_dir) +if not os.path.exists(build_dir): + raise RuntimeError("Couldn't find .so build dir: %s" % build_dir) +if build_dir not in sys.path: + sys.path.insert(0, build_dir) + +#------------------------------------------------------------------------ +# Ensure that placeholder package from auxiliary isn't imported +#------------------------------------------------------------------------ +sys.path = list(filter(lambda path: "auxiliary/libs" not in path, sys.path)) + import signalflow def process_tree(node, buffer=None, num_frames=signalflow.SIGNALFLOW_DEFAULT_BLOCK_SIZE): @@ -76,4 +88,4 @@ def graph(): # test fails (which can lead dangling references). Not doing this means that # all subsequent tests will fail with "AudioGraph has already been created". #-------------------------------------------------------------------------------- - graph.destroy() \ No newline at end of file + graph.destroy()