From 13323dcbda53ff42f434981e5d6df03a787fd9aa Mon Sep 17 00:00:00 2001 From: Arash Rouhani Date: Tue, 3 Jan 2017 15:23:30 +0700 Subject: [PATCH] target_test.py: Use clean paths to avoid failures Currently some tests will fail if you run them twice, because there's no proper cleanup done. --- test/target_test.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/target_test.py b/test/target_test.py index 4f94721202..0ca4aafaba 100644 --- a/test/target_test.py +++ b/test/target_test.py @@ -19,6 +19,7 @@ from helpers import unittest, skipOnTravis from mock import Mock import re +import random import luigi.target import luigi.format @@ -251,23 +252,25 @@ def test_move_on_fs(self): # We're cheating and retrieving the fs from target. # TODO: maybe move to "filesystem_test.py" or something t = self.create_target() + other_path = t.path + '-' + str(random.randint(0, 999999999)) t._touchz() fs = t.fs self.assertTrue(t.exists()) - fs.move(t.path, t.path+"-yay") + fs.move(t.path, other_path) self.assertFalse(t.exists()) def test_rename_dont_move_on_fs(self): # We're cheating and retrieving the fs from target. # TODO: maybe move to "filesystem_test.py" or something t = self.create_target() + other_path = t.path + '-' + str(random.randint(0, 999999999)) t._touchz() fs = t.fs self.assertTrue(t.exists()) - fs.rename_dont_move(t.path, t.path+"-yay") + fs.rename_dont_move(t.path, other_path) self.assertFalse(t.exists()) self.assertRaises(luigi.target.FileAlreadyExists, - lambda: fs.rename_dont_move(t.path, t.path+"-yay")) + lambda: fs.rename_dont_move(t.path, other_path)) class TemporaryPathTest(unittest.TestCase):