From: Daira Hopwood Date: Fri, 5 Feb 2016 19:12:01 +0000 (+0000) Subject: Fix tests on platforms without time.tzset (e.g. Windows). fixes ticket:2725 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/%3C?a=commitdiff_plain;h=refs%2Fpull%2F236%2Fhead;p=tahoe-lafs%2Ftahoe-lafs.git Fix tests on platforms without time.tzset (e.g. Windows). fixes ticket:2725 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index 9e8149d1..c95f7168 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -195,6 +195,9 @@ class TimezoneMixin(object): self.addCleanup(restoreTimezone) tzset_if_possible() + def have_working_tzset(self): + return hasattr(time, 'tzset') + try: import win32file diff --git a/src/allmydata/test/test_util.py b/src/allmydata/test/test_util.py index 25b65615..be5541e8 100644 --- a/src/allmydata/test/test_util.py +++ b/src/allmydata/test/test_util.py @@ -932,6 +932,10 @@ class TimeFormat(unittest.TestCase, TimezoneMixin): # time_format.iso_utc_time_to_localseconds() breaks if the timezone is # Europe/London. (As soon as this unit test is done then I'll change # that implementation to something that works even in this case...) + + if not self.have_working_tzset(): + raise unittest.SkipTest("This test can't be run on a platform without time.tzset().") + self.setTimezone("Europe/London") return self._help_test_epoch() diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 18514a3a..2a968f9a 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -634,10 +634,25 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi self.failUnlessIn(u'fake_nickname \u263A', res_u) self.failUnlessIn(u'
other_nickname \u263B
', res_u) self.failUnlessIn(u'Connected to 1\n of 2 known storage servers', res_u) - self.failUnless(re.search(u'
\n 1d\u00A00h\u00A00m\u00A050s', res_u), repr(res_u)) - self.failUnless(re.search(u'
\n 1d\u00A00h\u00A00m\u00A035s', res_u), repr(res_u)) - self.failUnless(re.search(u'1d\u00A00h\u00A00m\u00A030s', res_u), repr(res_u)) - self.failUnless(re.search(u'1d\u00A00h\u00A00m\u00A025s', res_u), repr(res_u)) + def timestamp(t): + return (u'"%s"' % (t,)) if self.have_working_tzset() else u'"[^"]*"' + self.failUnless(re.search( + u'
' + u'
\n 1d\u00A00h\u00A00m\u00A050s' + % timestamp(u'1970-01-01 13:00:10'), res_u), repr(res_u)) + self.failUnless(re.search( + u'
' + u'
\n 1d\u00A00h\u00A00m\u00A035s' + % timestamp(u'1970-01-01 13:00:25'), res_u), repr(res_u)) + self.failUnless(re.search( + u'' + u'1d\u00A00h\u00A00m\u00A030s' + % timestamp(u'1970-01-01 13:00:30'), res_u), repr(res_u)) + self.failUnless(re.search( + u'' + u'1d\u00A00h\u00A00m\u00A025s' + % timestamp(u'1970-01-01 13:00:35'), res_u), repr(res_u)) + self.failUnlessIn(u'\u00A9 Tahoe-LAFS Software Foundation', res_u) self.failUnlessIn('

Available

', res) self.failUnlessIn('123.5kB', res)