]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix tests on platforms without time.tzset (e.g. Windows). fixes ticket:2725 236/head
authorDaira Hopwood <daira@jacaranda.org>
Fri, 5 Feb 2016 19:12:01 +0000 (19:12 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 5 Feb 2016 19:14:09 +0000 (19:14 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/common_util.py
src/allmydata/test/test_util.py
src/allmydata/test/test_web.py

index 9e8149d13583790c12ad61fb1a5331d5316cf709..c95f71681ff10dca701bcb4d238aaeec02abfe63 100644 (file)
@@ -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
index 25b656156ee1cec51752e0f29b5a0ef98c7d1eac..be5541e8852d79f8a3a5672652709af8851fa241 100644 (file)
@@ -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()
 
index 18514a3a57b012bbebf4cbe3d35b9a9e9d3571cf..2a968f9aed4f5087b6dd74849e9a0e69568364e2 100644 (file)
@@ -634,10 +634,25 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
             self.failUnlessIn(u'<td>fake_nickname \u263A</td>', res_u)
             self.failUnlessIn(u'<div class="nickname">other_nickname \u263B</div>', res_u)
             self.failUnlessIn(u'Connected to <span>1</span>\n              of <span>2</span> known storage servers', res_u)
-            self.failUnless(re.search(u'<div class="status-indicator"><img (src="img/connected-yes.png" |alt="Connected" ){2}/></div>\n                <a( class="timestamp"| title="1970-01-01 13:00:10"){2}>1d\u00A00h\u00A00m\u00A050s</a>', res_u), repr(res_u))
-            self.failUnless(re.search(u'<div class="status-indicator"><img (src="img/connected-no.png" |alt="Disconnected" ){2}/></div>\n                <a( class="timestamp"| title="1970-01-01 13:00:25"){2}>1d\u00A00h\u00A00m\u00A035s</a>', res_u), repr(res_u))
-            self.failUnless(re.search(u'<td class="service-last-received-data"><a( class="timestamp"| title="1970-01-01 13:00:30"){2}>1d\u00A00h\u00A00m\u00A030s</a></td>', res_u), repr(res_u))
-            self.failUnless(re.search(u'<td class="service-last-received-data"><a( class="timestamp"| title="1970-01-01 13:00:35"){2}>1d\u00A00h\u00A00m\u00A025s</a></td>', res_u), repr(res_u))
+            def timestamp(t):
+                return (u'"%s"' % (t,)) if self.have_working_tzset() else u'"[^"]*"'
+            self.failUnless(re.search(
+                u'<div class="status-indicator"><img (src="img/connected-yes.png" |alt="Connected" ){2}/>'
+                u'</div>\n                <a( class="timestamp"| title=%s){2}>1d\u00A00h\u00A00m\u00A050s</a>'
+                % timestamp(u'1970-01-01 13:00:10'), res_u), repr(res_u))
+            self.failUnless(re.search(
+                u'<div class="status-indicator"><img (src="img/connected-no.png" |alt="Disconnected" ){2}/>'
+                u'</div>\n                <a( class="timestamp"| title=%s){2}>1d\u00A00h\u00A00m\u00A035s</a>'
+                % timestamp(u'1970-01-01 13:00:25'), res_u), repr(res_u))
+            self.failUnless(re.search(
+                u'<td class="service-last-received-data"><a( class="timestamp"| title=%s){2}>'
+                u'1d\u00A00h\u00A00m\u00A030s</a></td>'
+                % timestamp(u'1970-01-01 13:00:30'), res_u), repr(res_u))
+            self.failUnless(re.search(
+                u'<td class="service-last-received-data"><a( class="timestamp"| title=%s){2}>'
+                u'1d\u00A00h\u00A00m\u00A025s</a></td>'
+                % timestamp(u'1970-01-01 13:00:35'), res_u), repr(res_u))
+
             self.failUnlessIn(u'\u00A9 <a href="https://tahoe-lafs.org/">Tahoe-LAFS Software Foundation', res_u)
             self.failUnlessIn('<td><h3>Available</h3></td>', res)
             self.failUnlessIn('123.5kB', res)