From c9738a0cd164d5d0d6777aa24c8dfd3b92a74448 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Thu, 9 Aug 2018 12:10:59 -0400 Subject: [PATCH] Ensure snippet tests can import other snippets --- tests/test_snippets.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_snippets.py b/tests/test_snippets.py index 7805cba4e..34faa3afd 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -53,7 +53,9 @@ def perform_test(filename, method, test_type): def run_via_cpython(filename): """ Simply invoke python itself on the script """ - subprocess.check_call([sys.executable, filename]) + env = os.environ.copy() + env['PYTHONPATH'] = '.' + subprocess.check_call([sys.executable, filename], env=env) def run_via_cpython_bytecode(filename, test_type): @@ -76,8 +78,12 @@ def run_via_rustpython(filename, test_type): log_level = 'info' if test_type == _TestType.benchmark else 'trace' env['RUST_LOG'] = '{},cargo=error,jobserver=error'.format(log_level) env['RUST_BACKTRACE'] = '1' + # XXX: Once we support PYTHONPATH (or similar), we should use that instead + # of changing directory + cwd = os.path.dirname(filename) with pushd(RUSTPYTHON_RUNNER_DIR): - subprocess.check_call(['cargo', 'run', '--release', filename], env=env) + subprocess.check_call( + ['cargo', 'run', '--release', filename], env=env, cwd=cwd) def create_test_function(cls, filename, method, test_type):