mirror of https://github.com/flaggo/pydu.git
add test for file.link
This commit is contained in:
parent
afe7fa6bdc
commit
d60bc2e3b8
|
@ -92,6 +92,11 @@ def copy(src, dst, ignore_errors=False, follow_symlinks=True):
|
|||
raise OSError('Copy {} to {} error'.format(src, dst))
|
||||
|
||||
|
||||
def touch(path):
|
||||
with open(path, 'w'):
|
||||
pass
|
||||
|
||||
|
||||
if not WINDOWS:
|
||||
def link(src, dst, overwrite=False, ignore_errors=False):
|
||||
try:
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import os
|
||||
import pytest
|
||||
from pydu.file import makedirs
|
||||
from pydu.platform import WINDOWS
|
||||
from pydu.file import makedirs, remove, removes, open_file, copy, touch
|
||||
|
||||
if not WINDOWS:
|
||||
from pydu.file import link
|
||||
|
||||
|
||||
class TestMakeDirs:
|
||||
|
@ -35,3 +39,17 @@ class TestMakeDirs:
|
|||
assert os.path.exists(path)
|
||||
|
||||
|
||||
def test_touch(tmpdir):
|
||||
path = str(tmpdir.join('test'))
|
||||
touch(path)
|
||||
assert os.path.isfile(path)
|
||||
|
||||
|
||||
@pytest.mark.skipIf(WINDOWS)
|
||||
class TestLink:
|
||||
def test_link(self, tmpdir):
|
||||
src = str(tmpdir.join('src'))
|
||||
dst = str(tmpdir.join('dst'))
|
||||
touch(src)
|
||||
link(src, dst)
|
||||
assert os.path.exists(dst)
|
||||
|
|
Loading…
Reference in New Issue