Skip to content

Commit

Permalink
target_test.py: Use clean paths to avoid failures (spotify#1978)
Browse files Browse the repository at this point in the history
Currently some tests will fail if you run them twice, because there's no
proper cleanup done.
  • Loading branch information
Tarrasch authored and kreczko committed Mar 28, 2017
1 parent 4f9a076 commit 9e10942
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/target_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from helpers import unittest, skipOnTravis
from mock import Mock
import re
import random

import luigi.target
import luigi.format
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9e10942

Please sign in to comment.