From c2aca7942858f1706dcc920da574bc614632fdeb Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 10 Nov 2016 01:14:14 +0100 Subject: [PATCH] Ensured tests can be run from any directory. --- sandbox_fs_test.py | 4 +++- tools_test.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sandbox_fs_test.py b/sandbox_fs_test.py index 8b97b98..884ad81 100755 --- a/sandbox_fs_test.py +++ b/sandbox_fs_test.py @@ -11,6 +11,7 @@ import unittest tempfile.tempdir = os.getcwd() # This tests fails when using /tmp. +VIGIL_ROOT = os.path.dirname(__file__) def _get_test_paths(temp_dir): @@ -26,7 +27,8 @@ class SandboxFilesystemTestCase(unittest.TestCase): with tempfile.TemporaryDirectory() as temp_dir: a_dir, foo_path, bar_path = _get_test_paths(temp_dir) os.mkdir(a_dir) - subprocess.check_call(["./sandbox_fs", a_dir, "--", __file__, + sandbox_fs_path = os.path.join(VIGIL_ROOT, "sandbox_fs") + subprocess.check_call([sandbox_fs_path, a_dir, "--", __file__, temp_dir]) self.assertTrue(os.path.exists(foo_path)) self.assertFalse(os.path.exists(bar_path)) diff --git a/tools_test.py b/tools_test.py index 9746c86..3bf0437 100755 --- a/tools_test.py +++ b/tools_test.py @@ -41,7 +41,7 @@ def result_path(tool, input_filename): def run_tool(tool, input_filename): - with chdir("golden-files"): + with chdir(os.path.join(VIGIL_ROOT, "golden-files")): return tool(os.path.join(".", "input", input_filename))