Add test for makedirs

This commit is contained in:
xuzg 2017-11-30 09:23:40 +08:00
parent 9739b94831
commit 23845c8cbb
1 changed files with 32 additions and 0 deletions

32
tests/test_file.py Normal file
View File

@ -0,0 +1,32 @@
import os
from pydu.file import makedirs
import pytest
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)
with pytest.raises(Exception) as e_info:
makedirs(path, exist_ok=True)
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) as e_info:
makedirs(path, ignore_errors=False)
def test_makedirs_with_mutl_dirs(self, tmpdir):
path = str(tmpdir.join('test/test'))
makedirs(path)
assert os.path.exists(path)