From a79dc9b35b22cb6dbc156f74da24d078a46e22ee Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Fri, 16 Apr 2021 15:07:25 -0400 Subject: [PATCH] Fix test failure caused by pytest update pytest 6.2.3 changed tmp directories from tmp_path to be private to the user instead of world-writable. See https://github.com/pytest-dev/pytest/issues/8414 Since I am running the tests as root in the container, this meant that when I "change_user('student')" I couldn't create any files since the working_dir wasn't writable. This is a quick hack to make the working_dir fixture chmod the tmp directory to be world-writable again. --- tests/docker_tests/conftest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/docker_tests/conftest.py b/tests/docker_tests/conftest.py index 0d5f449..9c5c5c4 100644 --- a/tests/docker_tests/conftest.py +++ b/tests/docker_tests/conftest.py @@ -18,7 +18,12 @@ def umask000(): @pytest.fixture() def working_dir(tmp_path): - """ Creates a temporary directory and sets it as the working directory. Retuns a path to the directory. """ + """ + Creates a temporary directory and sets it as the working directory. + Returns a path to the directory. Also sets the directory world-writable so we can test permissions and stuff in it. + """ os.chdir(tmp_path) + # tmp_path by default is private to the test runner (root) meaning "student" can't create anything in it. + os.chmod(tmp_path, 0o777) # world-writable return tmp_path