Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_win32_on_unix(self):
# Yes, winreg is all mocked out, but this test means we at least
# catch syntax errors, etc.
winreg = mock.MagicMock()
winreg.OpenKey = mock.MagicMock()
winreg.OpenKey.close = mock.MagicMock()
winreg.QueryInfoKey = mock.MagicMock(return_value=(1, 1))
winreg.EnumValue = mock.MagicMock(
return_value=('TimeZoneKeyName','Belarus Standard Time'))
winreg.EnumKey = mock.Mock(return_value='Bahia Standard Time')
sys.modules['winreg'] = winreg
import tzlocal.win32
tz = tzlocal.win32.get_localzone()
self.assertEqual(tz.zone, 'Europe/Minsk')
tzlocal.win32.valuestodict = mock.Mock(return_value={
'StandardName': 'Mocked Standard Time',
'Std': 'Mocked Standard Time',
})
tz = tzlocal.win32.reload_localzone()
self.assertEqual(tz.zone, 'America/Bahia')
def test_win32_on_unix(self):
# Yes, winreg is all mocked out, but this test means we at least
# catch syntax errors, etc.
winreg = mock.MagicMock()
winreg.OpenKey = mock.MagicMock()
winreg.OpenKey.close = mock.MagicMock()
winreg.QueryInfoKey = mock.MagicMock(return_value=(1, 1))
winreg.EnumValue = mock.MagicMock(
return_value=('TimeZoneKeyName', 'Belarus Standard Time'))
winreg.EnumKey = mock.Mock(return_value='Bahia Standard Time')
sys.modules['winreg'] = winreg
import tzlocal.win32
tz = tzlocal.win32.get_localzone()
self.assertEqual(tz.zone, 'Europe/Minsk')
tzlocal.win32.valuestodict = mock.Mock(
return_value={
'StandardName': 'Mocked Standard Time',
'Std': 'Mocked Standard Time',
})
tz = tzlocal.win32.reload_localzone()
self.assertEqual(tz.zone, 'America/Bahia')
def test_win32_on_unix(self):
# Yes, winreg is all mocked out, but this test means we at least
# catch syntax errors, etc.
winreg = mock.MagicMock()
winreg.OpenKey = mock.MagicMock()
winreg.OpenKey.close = mock.MagicMock()
winreg.QueryInfoKey = mock.MagicMock(return_value=(1, 1))
winreg.EnumValue = mock.MagicMock(
return_value=('TimeZoneKeyName','Belarus Standard Time'))
winreg.EnumKey = mock.Mock(return_value='Bahia Standard Time')
sys.modules['winreg'] = winreg
import tzlocal.win32
tz = tzlocal.win32.get_localzone()
self.assertEqual(tz.zone, 'Europe/Minsk')
tzlocal.win32.valuestodict = mock.Mock(return_value={
'StandardName': 'Mocked Standard Time',
'Std': 'Mocked Standard Time',
})
tz = tzlocal.win32.reload_localzone()
self.assertEqual(tz.zone, 'America/Bahia')
def test_win32_on_unix(self, atomock):
# Yes, winreg is all mocked out, but this test means we at least
# catch syntax errors, etc.
winreg = mock.MagicMock()
winreg.OpenKey = mock.MagicMock()
winreg.OpenKey.close = mock.MagicMock()
winreg.QueryInfoKey = mock.MagicMock(return_value=(1, 1))
winreg.EnumValue = mock.MagicMock(
return_value=('TimeZoneKeyName','Belarus Standard Time'))
winreg.EnumKey = mock.Mock(return_value='Bahia Standard Time')
sys.modules['winreg'] = winreg
import tzlocal.win32
tz = tzlocal.win32.get_localzone()
self.assertEqual(tz.zone, 'Europe/Minsk')
tzlocal.win32.valuestodict = mock.Mock(return_value={
'StandardName': 'Mocked Standard Time',
'Std': 'Mocked Standard Time',
})
tz = tzlocal.win32.reload_localzone()
self.assertEqual(tz.zone, 'America/Bahia')