Merge pull request #1242 from bjornars/fix/1240-tests-fail-on-32-bit

tests: fix test breakage due to promotion from int to long
This commit is contained in:
Stein Magnus Jodal 2015-08-05 22:46:32 +02:00
commit b51ee01c7c
4 changed files with 16 additions and 3 deletions

View File

@ -192,7 +192,8 @@ def _find(root, thread_count=10, relative=False, follow=False):
def find_mtimes(root, follow=False):
results, errors = _find(root, relative=False, follow=follow)
mtimes = dict((f, int(st.st_mtime * 1000)) for f, st in results.items())
# return the mtimes as integer milliseconds
mtimes = {f: int(st.st_mtime * 1000) for f, st in results.items()}
return mtimes, errors

View File

@ -32,6 +32,6 @@ class IsA(object):
return str(self.klass)
any_int = IsA(int)
any_int = IsA((int, long))
any_str = IsA(str)
any_unicode = IsA(compat.text_type)

View File

@ -40,7 +40,7 @@ class PlaybackHistoryTest(unittest.TestCase):
result = self.history.get_history()
(timestamp, ref) = result[0]
self.assertIsInstance(timestamp, int)
self.assertIsInstance(timestamp, (int, long))
self.assertEqual(track.uri, ref.uri)
self.assertIn(track.name, ref.name)
for artist in track.artists:

View File

@ -380,6 +380,18 @@ class FindMTimesTest(unittest.TestCase):
self.assertEqual(expected, result)
self.assertEqual({}, errors)
def test_gives_mtime_in_milliseconds(self):
fname = self.touch('foobar')
os.utime(fname, (1, 3.14159265))
result, errors = path.find_mtimes(fname)
self.assertEqual(len(result), 1)
mtime, = result.values()
self.assertEqual(mtime, 3141)
self.assertEqual(errors, {})
# TODO: kill this in favour of just os.path.getmtime + mocks
class MtimeTest(unittest.TestCase):