mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-17 10:20:13 +00:00
Make TimezoneMixin importable on Python 3.
This commit is contained in:
parent
72272cbf0b
commit
e90d1f38d2
@ -185,31 +185,6 @@ class TestMixin(SignalMixin):
|
|||||||
self.fail("Reactor was still active when it was required to be quiescent.")
|
self.fail("Reactor was still active when it was required to be quiescent.")
|
||||||
|
|
||||||
|
|
||||||
class TimezoneMixin(object):
|
|
||||||
|
|
||||||
def setTimezone(self, timezone):
|
|
||||||
def tzset_if_possible():
|
|
||||||
# Windows doesn't have time.tzset().
|
|
||||||
if hasattr(time, 'tzset'):
|
|
||||||
time.tzset()
|
|
||||||
|
|
||||||
unset = object()
|
|
||||||
originalTimezone = os.environ.get('TZ', unset)
|
|
||||||
def restoreTimezone():
|
|
||||||
if originalTimezone is unset:
|
|
||||||
del os.environ['TZ']
|
|
||||||
else:
|
|
||||||
os.environ['TZ'] = originalTimezone
|
|
||||||
tzset_if_possible()
|
|
||||||
|
|
||||||
os.environ['TZ'] = timezone
|
|
||||||
self.addCleanup(restoreTimezone)
|
|
||||||
tzset_if_possible()
|
|
||||||
|
|
||||||
def have_working_tzset(self):
|
|
||||||
return hasattr(time, 'tzset')
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import win32file
|
import win32file
|
||||||
import win32con
|
import win32con
|
||||||
|
@ -6,7 +6,7 @@ import time
|
|||||||
|
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
|
||||||
from allmydata.test.common_util import TimezoneMixin
|
from allmydata.test.common_py3 import TimezoneMixin
|
||||||
from allmydata.util import time_format
|
from allmydata.util import time_format
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from allmydata.util import statistics, dictutil, pipeline, yamlutil
|
|||||||
from allmydata.util import log as tahoe_log
|
from allmydata.util import log as tahoe_log
|
||||||
from allmydata.util.spans import Spans, overlap, DataSpans
|
from allmydata.util.spans import Spans, overlap, DataSpans
|
||||||
from allmydata.util.fileutil import EncryptedTemporaryFile
|
from allmydata.util.fileutil import EncryptedTemporaryFile
|
||||||
from allmydata.test.common_util import ReallyEqualMixin, TimezoneMixin
|
from allmydata.test.common_util import ReallyEqualMixin
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
long = int
|
long = int
|
||||||
|
@ -60,6 +60,7 @@ from .common import (
|
|||||||
from allmydata.interfaces import IMutableFileNode, SDMF_VERSION, MDMF_VERSION
|
from allmydata.interfaces import IMutableFileNode, SDMF_VERSION, MDMF_VERSION
|
||||||
from allmydata.mutable import servermap, publish, retrieve
|
from allmydata.mutable import servermap, publish, retrieve
|
||||||
from .. import common_util as testutil
|
from .. import common_util as testutil
|
||||||
|
from ..common_py3 import TimezoneMixin
|
||||||
from ..common_web import (
|
from ..common_web import (
|
||||||
do_http,
|
do_http,
|
||||||
Error,
|
Error,
|
||||||
@ -311,7 +312,7 @@ class FakeClient(_Client):
|
|||||||
|
|
||||||
MUTABLE_SIZELIMIT = FakeMutableFileNode.MUTABLE_SIZELIMIT
|
MUTABLE_SIZELIMIT = FakeMutableFileNode.MUTABLE_SIZELIMIT
|
||||||
|
|
||||||
class WebMixin(testutil.TimezoneMixin):
|
class WebMixin(TimezoneMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.setTimezone('UTC-13:00')
|
self.setTimezone('UTC-13:00')
|
||||||
self.s = FakeClient()
|
self.s = FakeClient()
|
||||||
|
@ -22,6 +22,7 @@ PORTED_MODULES = [
|
|||||||
"allmydata.util.namespace",
|
"allmydata.util.namespace",
|
||||||
"allmydata.util.pollmixin",
|
"allmydata.util.pollmixin",
|
||||||
"allmydata.util._python3",
|
"allmydata.util._python3",
|
||||||
|
"allmydata.test.common_py3",
|
||||||
]
|
]
|
||||||
|
|
||||||
PORTED_TEST_MODULES = [
|
PORTED_TEST_MODULES = [
|
||||||
|
Loading…
Reference in New Issue
Block a user