TST: Even more of conditioning of tests for cygwin

pull/316/merge
Yaroslav Halchenko 2013-08-08 22:25:14 -04:00
parent e4dad8dfc9
commit 511e0ace2e
2 changed files with 14 additions and 3 deletions

View File

@ -21,7 +21,7 @@ __author__ = "Cyril Jaquier, Yaroslav Halchenko"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko"
__license__ = "GPL" __license__ = "GPL"
import os, shutil, tempfile, unittest import os, tempfile, shutil, unittest
from client.configreader import ConfigReader from client.configreader import ConfigReader
from client.jailreader import JailReader from client.jailreader import JailReader
from client.jailsreader import JailsReader from client.jailsreader import JailsReader
@ -65,7 +65,12 @@ option = %s
self._write('d.conf', 0) self._write('d.conf', 0)
self.assertEqual(self._getoption('d'), 0) self.assertEqual(self._getoption('d'), 0)
os.chmod(f, 0) os.chmod(f, 0)
self.assertFalse(self.c.read('d')) # should not be readable BUT present # fragile test and known to fail e.g. under Cygwin where permissions
# seems to be not enforced, thus condition
if not os.access('d.conf', os.R_OK):
self.assertFalse(self.c.read('d')) # should not be readable BUT present
else:
raise unittest.SkipTest("Skipping on %s -- access rights are not enforced" % platform)
def testOptionalDotDDir(self): def testOptionalDotDDir(self):

View File

@ -83,7 +83,13 @@ def _assert_equal_entries(utest, found, output, count=None):
utest.assertEqual(found_time, output_time) utest.assertEqual(found_time, output_time)
if len(output) > 3 and count is None: # match matches if len(output) > 3 and count is None: # match matches
# do not check if custom count (e.g. going through them twice) # do not check if custom count (e.g. going through them twice)
utest.assertEqual(repr(found[3]), repr(output[3])) if os.linesep != '\n' or sys.platform.startswith('cygwin'):
# on those where text file lines end with '\r\n', override
# repr for this test to disregard trailing CR LF
srepr = lambda x: repr(str(x).rstrip('\n\r'))
else:
srepr = repr
utest.assertEqual(srepr(found[3]), srepr(output[3]))
def _assert_correct_last_attempt(utest, filter_, output, count=None): def _assert_correct_last_attempt(utest, filter_, output, count=None):
"""Additional helper to wrap most common test case """Additional helper to wrap most common test case