Skip to content

Commit

Permalink
Fix test failure caused by pytest update
Browse files Browse the repository at this point in the history
pytest 6.2.3 changed tmp directories from tmp_path to be private to the user
instead of world-writable. See pytest-dev/pytest#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.
  • Loading branch information
jesse-r-s-hines committed Apr 16, 2021
1 parent 5477514 commit a79dc9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/docker_tests/conftest.py
Expand Up @@ -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

0 comments on commit a79dc9b

Please sign in to comment.