mirror of https://github.com/flaggo/pydu.git
38 lines
999 B
Python
38 lines
999 B
Python
import os
|
|
import pytest
|
|
from pydu.file import makedirs
|
|
|
|
|
|
class TestMakeDirs:
|
|
def test_makedirs(self, tmpdir):
|
|
path = str(tmpdir.join('test'))
|
|
makedirs(path)
|
|
assert os.path.exists(path)
|
|
|
|
def test_makedirs_with_exists_path(self, tmpdir):
|
|
path = str(tmpdir.join('test'))
|
|
makedirs(path)
|
|
|
|
makedirs(path, exist_ok=True)
|
|
|
|
with pytest.raises(Exception):
|
|
makedirs(path, exist_ok=False)
|
|
|
|
def test_makedirs_with_ignore_error(self, tmpdir):
|
|
path = str(tmpdir.join('test'))
|
|
makedirs(path)
|
|
makedirs(path, ignore_errors=True)
|
|
|
|
def test_makedirs_without_ignore_error(self, tmpdir):
|
|
path = str(tmpdir.join('test'))
|
|
makedirs(path)
|
|
with pytest.raises(Exception):
|
|
makedirs(path, ignore_errors=False, exist_ok=False)
|
|
|
|
def test_makedirs_with_mutl_dirs(self, tmpdir):
|
|
path = str(tmpdir.join('test/test'))
|
|
makedirs(path)
|
|
assert os.path.exists(path)
|
|
|
|
|