|
@@ -62,10 +62,39 @@ def test_dir_exists(tmpdir):
|
|
with pytest.raises(OSError):
|
|
with pytest.raises(OSError):
|
|
osex.symlink("source", "dir", override = False)
|
|
osex.symlink("source", "dir", override = False)
|
|
|
|
|
|
-def test_override(tmpdir):
|
|
|
|
|
|
+def test_override_link(tmpdir):
|
|
os.chdir(tmpdir.strpath)
|
|
os.chdir(tmpdir.strpath)
|
|
osex.symlink("source1", "link")
|
|
osex.symlink("source1", "link")
|
|
assert os.path.lexists("link")
|
|
assert os.path.lexists("link")
|
|
- osex.symlink("source2", "link", override = True)
|
|
|
|
|
|
+ osex.symlink("source2", "link", override = True, backup = False, backup_suffix = "~")
|
|
assert os.path.lexists("link")
|
|
assert os.path.lexists("link")
|
|
assert os.readlink("link") == "source2"
|
|
assert os.readlink("link") == "source2"
|
|
|
|
+ assert not os.path.lexists("link~")
|
|
|
|
+
|
|
|
|
+def test_override_dir(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ os.mkdir("link")
|
|
|
|
+ assert os.path.exists("link")
|
|
|
|
+ osex.symlink("source", "link", override = True, backup = False, backup_suffix = "-")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ assert os.readlink("link") == "source"
|
|
|
|
+ assert not os.path.isdir("link-")
|
|
|
|
+
|
|
|
|
+def test_backup_link(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ osex.symlink("source1", "link")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ osex.symlink("source2", "link", override = True, backup = True, backup_suffix = "~")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ assert os.readlink("link") == "source2"
|
|
|
|
+ assert os.path.lexists("link~")
|
|
|
|
+ assert os.readlink("link~") == "source1"
|
|
|
|
+
|
|
|
|
+def test_backup_dir(tmpdir):
|
|
|
|
+ os.chdir(tmpdir.strpath)
|
|
|
|
+ os.mkdir("link")
|
|
|
|
+ assert os.path.exists("link")
|
|
|
|
+ osex.symlink("source", "link", override = True, backup = True, backup_suffix = "-")
|
|
|
|
+ assert os.path.lexists("link")
|
|
|
|
+ assert os.readlink("link") == "source"
|
|
|
|
+ assert os.path.isdir("link-")
|