From 4356501a31b5c0f1977e755ec2811ab0f7f5cd4a Mon Sep 17 00:00:00 2001 From: xzg Date: Wed, 6 Dec 2017 21:42:35 +0800 Subject: [PATCH] Add test for overwrite --- tests/test_file.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/test_file.py b/tests/test_file.py index b1a6115..08eabaf 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -162,10 +162,20 @@ class TestLink: with pytest.raises(Exception): link(d, link_d) + def test_link_with_overwrite(self, tmpdir): + f = str(tmpdir.join('test.txt')) + link_f = str(tmpdir.join('test.txt')) + touch(f) + link(f, link_f) + t1 = os.path.getctime(link_f) + link(f, link_f, overwrite=True) + t2 = os.path.getctime(link_f) + assert t1 != t2 + @pytest.mark.skipif(WINDOWS, reason='Not support on windows') class TestSymLink: - def test_link_a_file(self, tmpdir): + def test_symlink_a_file(self, tmpdir): f = str(tmpdir.join('test.txt')) link_f = str(tmpdir.join('test.link')) touch(f) @@ -173,16 +183,23 @@ class TestSymLink: assert os.path.exists(link_f) assert os.path.islink(link_f) - def test_link_with_ignore_error(self, tmpdir): + def test_symlink_with_ignore_error(self, tmpdir): d = str(tmpdir.join('test')) link_d = str(tmpdir.join('test.link')) makedirs(d) link(d, link_d, ignore_errors=True) - def test_link_with_overwrite(self,tmpdir): - pass + def test_symlink_with_overwrite(self, tmpdir): + f = str(tmpdir.join('test.txt')) + link_f = str(tmpdir.join('test.txt')) + touch(f) + symlink(f, link_f) + t1 = os.path.getctime(link_f) + symlink(f, link_f, overwrite=True) + t2 = os.path.getctime(link_f) + assert t1 != t2 - def test_link_without_ignore_error(self, tmpdir): + def test_symlink_without_ignore_error(self, tmpdir): d = str(tmpdir.join('test')) link_d = str(tmpdir.join('test.link')) makedirs(d)