Fix test_standarddir.TestCreatingDir

What we actually want to test here is that the given type directory is created
and has the correct permission, we don't care much about the basedir itself.

Also, the download dir is not created automatically.

This test failed on Python 3.7 because intermediate directories now aren't
created with the given mode anymore:

https://bugs.python.org/issue19930
https://docs.python.org/3.7/whatsnew/3.7.html#changes-in-the-python-api
This commit is contained in:
Florian Bruhin 2018-02-10 20:05:57 +01:00
parent cd1bd7d52a
commit 5f62c016cc

View File

@ -301,6 +301,7 @@ class TestCreatingDir:
"""Test --basedir."""
basedir = tmpdir / 'basedir'
assert not basedir.exists()
args = types.SimpleNamespace(basedir=str(basedir))
standarddir._init_dirs(args)
@ -309,8 +310,13 @@ class TestCreatingDir:
assert basedir.exists()
if utils.is_posix:
assert basedir.stat().mode & 0o777 == 0o700
if typ == 'download':
assert not (basedir / typ).exists()
else:
assert (basedir / typ).exists()
if utils.is_posix:
assert (basedir / typ).stat().mode & 0o777 == 0o700
@pytest.mark.parametrize('typ', DIR_TYPES)
def test_exists_race_condition(self, mocker, tmpdir, typ):