Skip to content

Commit

Permalink
Fix caching unit tests to not assume a specific directory separator
Browse files Browse the repository at this point in the history
  • Loading branch information
lxp committed Jul 30, 2021
1 parent 5d15b1c commit cd50222
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,31 @@ def test_rename(self):
class RelPathKeyTest(RelTestCase):
def test_nocase_findfile(self):
cache = FileInfoCache()
a1 = self.mkfile('aAaA/AaA1', '1')
self.mkfile('aAaA/Aaa2', '2')
self.mkfile('aAaA/AAa2', '3')
a1 = self.mkfile(os.path.join('aAaA', 'AaA1'), '1')
self.mkfile(os.path.join('aAaA', 'Aaa2'), '2')
self.mkfile(os.path.join('aAaA', 'AAa2'), '3')

self.assertEquals(a1, cache.nocase_findfile(self.mkpath('aaAA/aaa1')))
self.assertEquals(a1, cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa1'))))
with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAb/aaa1'))
cache.nocase_findfile(self.mkpath(os.path.join('aaAb', 'aaa1')))
self.assertEquals(errno.ENOENT, cm.exception.errno)

with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAA/aab1'))
cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aab1')))
self.assertEquals(errno.ENOENT, cm.exception.errno)

with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAA/aaa2'))
cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa2')))
self.assertEquals(errno.EEXIST, cm.exception.errno)

def test_nocase_findfile_parent(self):
cache = FileInfoCache()
self.mkfile('aaaA/aaA1', '1')
self.mkfile('aAaA/aaa2', '2')
self.mkfile(os.path.join('aaaA', 'aaA1'), '1')
self.mkfile(os.path.join('aAaA', 'aaa2'), '2')

# right now we don't handle this case, though it would be possible
# to generate all possible matches and see if the number is exactly
# one.
with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAA/aaa2'))
cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa2')))
self.assertEquals(errno.EEXIST, cm.exception.errno)

0 comments on commit cd50222

Please sign in to comment.