Skip to content

Commit

Permalink
tests: makedirs permissions test simplify with tmpdir fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein committed Nov 19, 2019
1 parent aa6a772 commit 1c752a9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/func/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,15 @@ def test_boxify(self):


@pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.")
def test_makedirs_permissions():
def test_makedirs_permissions(tmpdir):
dir_mode = 0o755
os.chdir(str(tmpdir))
intermediate_dir = "тестовая-директория"
test_dir = os.path.join(intermediate_dir, "data")

assert not os.path.exists(intermediate_dir)

try:
utils.makedirs(test_dir, mode=dir_mode)
assert stat.S_IMODE(os.stat(test_dir).st_mode) == dir_mode
assert stat.S_IMODE(os.stat(intermediate_dir).st_mode) == dir_mode
finally:
shutil.rmtree(intermediate_dir)
utils.makedirs(test_dir, mode=dir_mode)

assert stat.S_IMODE(os.stat(test_dir).st_mode) == dir_mode
assert stat.S_IMODE(os.stat(intermediate_dir).st_mode) == dir_mode

0 comments on commit 1c752a9

Please sign in to comment.