pydu/tests/test_file.py

33 lines
960 B
Python

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)