From 17d92a441d95a27af9448dc734aad794d2676d41 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 13 Feb 2018 15:03:18 +0200 Subject: [PATCH] test: use swap_code function Signed-off-by: Ruslan Kuprieiev --- tests/test_repro.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_repro.py b/tests/test_repro.py index d1305e1c3..b949e7ed4 100644 --- a/tests/test_repro.py +++ b/tests/test_repro.py @@ -27,15 +27,19 @@ class TestRepro(TestDvc): class TestReproChangedCode(TestRepro): def test(self): - repro = 'repro' - with open(self.CODE, 'a') as code: - code.write("\nshutil.copyfile('{}', sys.argv[2])\n".format(self.BAR)) + self.swap_code() stages = self.dvc.reproduce(self.file1_stage) self.assertTrue(filecmp.cmp(self.file1, self.BAR)) self.assertEqual(len(stages), 1) + def swap_code(self): + os.unlink(self.CODE) + new_contents = self.CODE_CONTENTS + new_contents += "\nshutil.copyfile('{}', sys.argv[2])\n".format(self.BAR) + self.create(self.CODE, new_contents) + class TestReproChangedData(TestRepro): def test(self):