From 511e0ace2e6081ef9b0378db961e232af13591eb Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 8 Aug 2013 22:25:14 -0400 Subject: [PATCH] TST: Even more of conditioning of tests for cygwin --- testcases/clientreadertestcase.py | 9 +++++++-- testcases/filtertestcase.py | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/testcases/clientreadertestcase.py b/testcases/clientreadertestcase.py index 4e8cdd9d..b52ad618 100644 --- a/testcases/clientreadertestcase.py +++ b/testcases/clientreadertestcase.py @@ -21,7 +21,7 @@ __author__ = "Cyril Jaquier, Yaroslav Halchenko" __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2013 Yaroslav Halchenko" __license__ = "GPL" -import os, shutil, tempfile, unittest +import os, tempfile, shutil, unittest from client.configreader import ConfigReader from client.jailreader import JailReader from client.jailsreader import JailsReader @@ -65,7 +65,12 @@ option = %s self._write('d.conf', 0) self.assertEqual(self._getoption('d'), 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): diff --git a/testcases/filtertestcase.py b/testcases/filtertestcase.py index b961d0dc..ecdc7bde 100644 --- a/testcases/filtertestcase.py +++ b/testcases/filtertestcase.py @@ -83,7 +83,13 @@ def _assert_equal_entries(utest, found, output, count=None): utest.assertEqual(found_time, output_time) if len(output) > 3 and count is None: # match matches # 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): """Additional helper to wrap most common test case