From 23552223725aaea6c7a682e89b68ef8502697592 Mon Sep 17 00:00:00 2001 From: Chris Kerr Date: Thu, 22 Sep 2022 19:44:24 +0300 Subject: [PATCH] test_autowrap: Change to a temporary directory before testing writes to relative paths Fixes https://github.com/sympy/sympy/issues/24075 --- sympy/utilities/tests/test_autowrap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sympy/utilities/tests/test_autowrap.py b/sympy/utilities/tests/test_autowrap.py index 9c0adebdfd22..c8f85861a44d 100644 --- a/sympy/utilities/tests/test_autowrap.py +++ b/sympy/utilities/tests/test_autowrap.py @@ -261,12 +261,16 @@ def test_autowrap_store_files(): def test_autowrap_store_files_issue_gh12939(): x, y = symbols('x y') tmp = './tmp' + saved_cwd = os.getcwd() + temp_cwd = tempfile.mkdtemp() try: + os.chdir(temp_cwd) f = autowrap(x + y, backend='dummy', tempdir=tmp) assert f() == str(x + y) assert os.access(tmp, os.F_OK) finally: - shutil.rmtree(tmp) + os.chdir(saved_cwd) + shutil.rmtree(temp_cwd) def test_binary_function():