Skip to content

Commit

Permalink
Skip some incompatible tests on case-insenstive filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
lxp committed Jul 31, 2021
1 parent be3cb6e commit e24334b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions test/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def mkfile(self, name, contents):
f.write(contents)
return name

def readfile(self, name):
with open(name, 'rt') as f:
return f.read()


class AbsPathKeyTest(AbsTestCase):
def test_get_path_key(self):
Expand Down Expand Up @@ -136,6 +140,12 @@ def test_nocase_findfile(self):
self.mkfile('aAaA/Aaa2', '2')
self.mkfile('aAaA/AAa2', '3')

a2_content = self.readfile('aAaA/Aaa2')
self.assertIn(a2_content, ('2', '3'))
fs_case_sensitive = a2_content == '2'
if not fs_case_sensitive:
print('Skipping some tests due to case-insensitive filesystem')

self.assertEquals(a1, cache.nocase_findfile(self.mkpath('aaAA/aaa1')))
with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAb/aaa1'))
Expand All @@ -145,18 +155,24 @@ def test_nocase_findfile(self):
cache.nocase_findfile(self.mkpath('aaAA/aab1'))
self.assertEquals(errno.ENOENT, cm.exception.errno)

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

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

if not fs_case_sensitive:
print('Skipping some tests due to case-insensitive filesystem')

# 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'))
self.assertEquals(errno.EEXIST, cm.exception.errno)
if fs_case_sensitive:
with self.assertRaises(IOError) as cm:
cache.nocase_findfile(self.mkpath('aaAA/aaa2'))
self.assertEquals(errno.EEXIST, cm.exception.errno)

0 comments on commit e24334b

Please sign in to comment.