|
@@ -3,7 +3,6 @@ import pytest
|
|
import osex
|
|
import osex
|
|
|
|
|
|
import os
|
|
import os
|
|
-import sys
|
|
|
|
|
|
|
|
def test_new(tmpdir):
|
|
def test_new(tmpdir):
|
|
os.chdir(tmpdir.strpath)
|
|
os.chdir(tmpdir.strpath)
|
|
@@ -11,7 +10,16 @@ def test_new(tmpdir):
|
|
assert os.path.lexists("link")
|
|
assert os.path.lexists("link")
|
|
assert os.readlink("link") == "source"
|
|
assert os.readlink("link") == "source"
|
|
|
|
|
|
-def test_absolute(tmpdir):
|
|
|
|
|
|
+def test_absolute1(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ os.makedirs(os.path.join("1", "2"))
|
|
|
|
+ link = os.path.join("1", "2", "link")
|
|
|
|
+ source = os.path.join(os.getcwd(), "1", "source")
|
|
|
|
+ osex.symlink(source, link)
|
|
|
|
+ assert os.path.lexists(link)
|
|
|
|
+ assert os.readlink(link) == source
|
|
|
|
+
|
|
|
|
+def test_absolute2(tmpdir):
|
|
os.chdir(tmpdir.strpath)
|
|
os.chdir(tmpdir.strpath)
|
|
os.makedirs(os.path.join("1", "2"))
|
|
os.makedirs(os.path.join("1", "2"))
|
|
link = os.path.join("1", "2", "link")
|
|
link = os.path.join("1", "2", "link")
|
|
@@ -28,3 +36,20 @@ def test_relative(tmpdir):
|
|
osex.symlink(source, link, relative = True)
|
|
osex.symlink(source, link, relative = True)
|
|
assert os.path.lexists(link)
|
|
assert os.path.lexists(link)
|
|
assert os.readlink(link) == "../source"
|
|
assert os.readlink(link) == "../source"
|
|
|
|
+
|
|
|
|
+def test_exists(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ osex.symlink("source1", "link")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ with pytest.raises(OSError):
|
|
|
|
+ osex.symlink("source2", "link")
|
|
|
|
+ with pytest.raises(OSError):
|
|
|
|
+ osex.symlink("source3", "link", override = False)
|
|
|
|
+
|
|
|
|
+def test_override(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ osex.symlink("source1", "link")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ osex.symlink("source2", "link", override = True)
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ assert os.readlink("link") == "source2"
|