From 2385392cd5c264e2a16e74bab12113606b3a070e Mon Sep 17 00:00:00 2001 From: Tammo Behrends Date: Wed, 8 Mar 2017 15:14:52 +0100 Subject: [PATCH 1/2] Fix python version used to run tests Even if the test runner itself is executed with a specific python version the subprocess used to execute the respective test script always uses the generic 'python' found in the PATH. On most systems that have python2 & 3 installed 'python' is a symlink to 'python2.X'. So this would mean that even if you would run 'python3 ./test/...py' the tests would still be run with python2. --- test/check-exercises.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/check-exercises.py b/test/check-exercises.py index 985dd2ee660..59a80338367 100755 --- a/test/check-exercises.py +++ b/test/check-exercises.py @@ -12,6 +12,10 @@ import json +def python_executable_name(): + return 'python{}.{}'.format(sys.version_info.major, sys.version_info.minor) + + def check_assignment(name, test_file): # Returns the exit code of the tests workdir = tempfile.mkdtemp(name) @@ -21,7 +25,7 @@ def check_assignment(name, test_file): shutil.copyfile(test_file, test_file_out) shutil.copyfile(os.path.join(os.path.dirname(test_file), 'example.py'), os.path.join(workdir, '{}.py'.format(example_name))) - return subprocess.call(['python', test_file_out]) + return subprocess.call([python_executable_name(), test_file_out]) finally: shutil.rmtree(workdir) From b81b2f56b2758fc000823b0bd1b9e6609beaf539 Mon Sep 17 00:00:00 2001 From: Tammo Behrends Date: Sun, 19 Mar 2017 13:40:37 +0100 Subject: [PATCH 2/2] Add log line with python version --- test/check-exercises.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/check-exercises.py b/test/check-exercises.py index 59a80338367..29418dfe968 100755 --- a/test/check-exercises.py +++ b/test/check-exercises.py @@ -95,6 +95,8 @@ def main(): failures.append('{} (TestFailed)'.format(exercise)) print('') + print('TestEnvironment:', python_executable_name().capitalize(), end='\n\n') + if failures: print('FAILURES: ', ', '.join(failures)) raise SystemExit(1)