Browse Source

symlink: added test expecting OSError if a existing dir is specified as link_name

Fabian Peter Hammerle 8 years ago
parent
commit
14d9ea552d
1 changed files with 10 additions and 1 deletions
  1. 10 1
      tests/test_symlink.py

+ 10 - 1
tests/test_symlink.py

@@ -37,7 +37,7 @@ def test_relative(tmpdir):
     assert os.path.lexists(link)
     assert os.readlink(link) == "../source"
 
-def test_exists(tmpdir):
+def test_link_exists(tmpdir):
     os.chdir(tmpdir.strpath)
     osex.symlink("source1", "link")
     assert os.path.lexists("link")
@@ -46,6 +46,15 @@ def test_exists(tmpdir):
     with pytest.raises(OSError):
         osex.symlink("source3", "link", override = False)
 
+def test_dir_exists(tmpdir):
+    os.chdir(tmpdir.strpath)
+    os.mkdir("dir")
+    assert os.path.exists("dir")
+    with pytest.raises(OSError):
+        osex.symlink("source", "dir")
+    with pytest.raises(OSError):
+        osex.symlink("source", "dir", override = False)
+
 def test_override(tmpdir):
     os.chdir(tmpdir.strpath)
     osex.symlink("source1", "link")