aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/test_dotfile.py106
1 files changed, 33 insertions, 73 deletions
diff --git a/tests/test_dotfile.py b/tests/test_dotfile.py
index b854859..e679caf 100644
--- a/tests/test_dotfile.py
+++ b/tests/test_dotfile.py
@@ -3,34 +3,21 @@ import py.error
from dotfiles.dotfile import Dotfile
-class TestAdd:
+@pytest.mark.parametrize("times", range(1, 4))
+def test_add(tmpdir, times):
- def test_add(self, tmpdir):
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.ensure(".vimrc")
+ target = repo.join("vimrc")
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.ensure(".vimrc")
- target = repo.join("vimrc")
+ dotfile = Dotfile(name, target)
+ dotfile.add()
- dotfile = Dotfile(name, target)
- dotfile.add()
-
- assert target.check(file=1, link=0)
- assert name.check(file=1, link=1)
- assert name.samefile(target)
-
- def test_add_twice(self, tmpdir):
-
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.ensure(".vimrc")
- target = repo.join("vimrc")
-
- dotfile = Dotfile(name, target)
- dotfile.add()
-
- assert target.check(file=1, link=0)
- assert name.check(file=1, link=1)
- assert name.samefile(target)
+ assert target.check(file=1, link=0)
+ assert name.check(file=1, link=1)
+ assert name.samefile(target)
+ for x in range(2, times):
with pytest.raises(OSError):
dotfile.add()
@@ -39,36 +26,22 @@ class TestAdd:
assert name.samefile(target)
-class TestRemove:
-
- def test_remove(self, tmpdir):
-
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.join(".vimrc")
- target = repo.ensure("vimrc")
-
- name.mksymlinkto(target)
-
- dotfile = Dotfile(name, target)
- dotfile.remove()
-
- assert False == target.check()
- assert name.check(file=1, link=0)
+@pytest.mark.parametrize("times", range(1, 4))
+def test_remove(tmpdir, times):
- def test_remove_twice(self, tmpdir):
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.ensure("vimrc")
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.join(".vimrc")
- target = repo.ensure("vimrc")
+ name.mksymlinkto(target)
- name.mksymlinkto(target)
+ dotfile = Dotfile(name, target)
+ dotfile.remove()
- dotfile = Dotfile(name, target)
- dotfile.remove()
-
- assert False == target.check()
- assert name.check(file=1, link=0)
+ assert False == target.check()
+ assert name.check(file=1, link=0)
+ for x in range(2, times):
with pytest.raises(OSError):
dotfile.remove()
@@ -76,34 +49,21 @@ class TestRemove:
assert name.check(file=1, link=0)
-class TestSync:
-
- def test_sync(self, tmpdir):
-
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.join(".vimrc")
- target = repo.ensure("vimrc")
-
- dotfile = Dotfile(name, target)
- dotfile.sync()
+@pytest.mark.parametrize("times", range(1, 4))
+def test_sync(tmpdir, times):
- assert target.check(file=1, link=0)
- assert name.check(file=1, link=1)
- assert name.samefile(target)
-
- def test_sync_twice(self, tmpdir):
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.ensure("vimrc")
- repo = tmpdir.ensure("Dotfiles", dir=1)
- name = tmpdir.join(".vimrc")
- target = repo.ensure("vimrc")
+ dotfile = Dotfile(name, target)
+ dotfile.sync()
- dotfile = Dotfile(name, target)
- dotfile.sync()
-
- assert target.check(file=1, link=0)
- assert name.check(file=1, link=1)
- assert name.samefile(target)
+ assert target.check(file=1, link=0)
+ assert name.check(file=1, link=1)
+ assert name.samefile(target)
+ for x in range(2, times):
with pytest.raises(py.error.EEXIST):
dotfile.sync()