def test_dir_does_not_exist_and_not_allowed_to_create(self, capsys): logging.basicConfig(stream=sys.stdout) # TODO find a way to test it on macos and win _ensure_dir_exists("/root/toto") out, err = capsys.readouterr() assert 'Permission denied' in out and err == ''
def test_dir_already_exists(self, capsys): logging.basicConfig(stream=sys.stdout) assert tempfile.gettempdir() is not None assert exists(tempfile.gettempdir()) _ensure_dir_exists(tempfile.gettempdir()) out, err = capsys.readouterr() assert out == '' and err == ''
def test_dir_does_not_exist_and_allowed_to_create(self, capsys): logging.basicConfig(stream=sys.stdout) assert tempfile.gettempdir() is not None newRandomPath = join(tempfile.gettempdir(), str(uuid.uuid4())) assert not exists(newRandomPath) _ensure_dir_exists(newRandomPath) out, err = capsys.readouterr() assert out == '' and err == '' os.rmdir(newRandomPath)