summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Driessen <vincent@3rdcloud.com>2012-02-18 13:13:40 +0100
committerVincent Driessen <vincent@3rdcloud.com>2012-02-18 13:13:40 +0100
commit69cf3caf565c586d534b5071e024648ca27ff1a4 (patch)
treeed27bc783bed0c7b7f51ef4b2932dad102a41590
parent220df60a867592ecd47eb75c5b56cafda95c947a (diff)
downloadtimes-69cf3caf565c586d534b5071e024648ca27ff1a4.tar.gz
Flake8.
-rw-r--r--setup.py2
-rw-r--r--tests/test_times.py49
2 files changed, 28 insertions, 23 deletions
diff --git a/setup.py b/setup.py
index 6b44b70..7d1fa0c 100644
--- a/setup.py
+++ b/setup.py
@@ -2,6 +2,7 @@ import sys
import os
from setuptools import setup
+
def get_version():
basedir = os.path.dirname(__file__)
with open(os.path.join(basedir, 'times/version.py')) as f:
@@ -10,6 +11,7 @@ def get_version():
return VERSION
raise RuntimeError('No version info found.')
+
def get_dependencies():
deps = ['pytz']
if sys.version_info[0] == 3: # Python >= 3
diff --git a/tests/test_times.py b/tests/test_times.py
index 10d7f1c..3fedef9 100644
--- a/tests/test_times.py
+++ b/tests/test_times.py
@@ -1,5 +1,6 @@
from unittest import TestCase
-import times, pytz
+import times
+import pytz
from datetime import datetime
@@ -8,23 +9,23 @@ class TestTimes(TestCase):
est = pytz.timezone('EST')
ams = pytz.timezone('Europe/Amsterdam')
- self.sometime_in_newyork = est.localize(datetime(2012, 2, 1, 6, 56, 31))
- self.sometime_in_amsterdam = ams.localize(datetime(2012, 2, 1, 12, 56, 31))
+ self.time_in_ny = est.localize(datetime(2012, 2, 1, 6, 56, 31))
+ self.time_in_ams = ams.localize(datetime(2012, 2, 1, 12, 56, 31))
self.sometime_univ = datetime(2012, 2, 1, 11, 56, 31)
# now()
- def test_now(self):
+ def test_now(self): # noqa
"""times.now() has no attached timezone info"""
now = times.now()
self.assertIsNone(now.tzinfo)
# to_universal()
- def test_to_universal_with_tzinfo(self):
+ def test_to_universal_with_tzinfo(self): # noqa
"""Convert local dates with timezone info to universal date"""
- ny_time = self.sometime_in_newyork
- ams_time = self.sometime_in_amsterdam
+ ny_time = self.time_in_ny
+ ams_time = self.time_in_ams
self.assertEquals(
times.to_universal(ny_time),
@@ -51,8 +52,8 @@ class TestTimes(TestCase):
# Same as above, but with tzinfo stripped off (as if a NY and Amsterdam
# user used datetime.now())
- ny_time = self.sometime_in_newyork.replace(tzinfo=None)
- ams_time = self.sometime_in_amsterdam.replace(tzinfo=None)
+ ny_time = self.time_in_ny.replace(tzinfo=None)
+ ams_time = self.time_in_ams.replace(tzinfo=None)
# When time has no tzinfo attached, it should be specified explicitly
est = pytz.timezone('EST')
@@ -82,16 +83,18 @@ class TestTimes(TestCase):
self.assertEquals(dt, times.to_universal('2012-02-01 06:56:31-05:00'))
# Timezone-less strings require explicit source timezone
- self.assertEquals(dt, times.to_universal('2012-02-02 00:56:31', 'Pacific/Auckland'))
+ self.assertEquals(dt, times.to_universal('2012-02-02 00:56:31',
+ 'Pacific/Auckland'))
self.assertEquals(dt, times.to_universal('2012-02-01 12:56:31', 'CET'))
self.assertEquals(dt, times.to_universal('2012-02-01 06:56:31', 'EST'))
- # Timezone-less strings are rejected if source timezone is not specified
+ # Timezone-less strings are rejected if source timezone is not
+ # specified
with self.assertRaises(ValueError):
self.assertEquals(dt, times.to_universal('2012-02-01 12:56:31'))
- def test_to_universal_rejects_no_tzinfo(self):
+ def test_to_universal_rejects_no_tzinfo(self): # noqa
"""Converting to universal times requires source timezone"""
now = datetime.now()
with self.assertRaises(ValueError):
@@ -104,7 +107,7 @@ class TestTimes(TestCase):
# from_unix()
- def test_convert_unix_time_to_datetime(self):
+ def test_convert_unix_time_to_datetime(self): # noqa
"""Can convert from UNIX time to universal time."""
unix_time = 1328257004.456 # as returned by time.time()
self.assertEquals(
@@ -129,7 +132,7 @@ class TestTimes(TestCase):
# to_unix()
- def test_convert_datetime_to_unix_time(self):
+ def test_convert_datetime_to_unix_time(self): # noqa
"""Can convert UNIX time to universal time."""
self.assertEquals(
times.to_unix(datetime(2012, 2, 3, 8, 16, 44)),
@@ -143,31 +146,32 @@ class TestTimes(TestCase):
# to_local()
- def test_convert_universal_to_local(self):
+ def test_convert_universal_to_local(self): # noqa
"""Convert universal time to local time"""
univ = self.sometime_univ
self.assertEquals(
times.to_local(univ, pytz.timezone('Europe/Amsterdam')),
- self.sometime_in_amsterdam)
+ self.time_in_ams)
self.assertEquals(
times.to_local(univ, pytz.timezone('EST')),
- self.sometime_in_newyork)
+ self.time_in_ny)
def test_convert_refuses_local_to_local(self):
"""Refuses to convert between timezones directly"""
- loc = self.sometime_in_amsterdam
+ loc = self.time_in_ams
with self.assertRaises(ValueError):
times.to_local(loc, pytz.timezone('Europe/Amsterdam'))
# format()
- def test_format_without_tzinfo(self):
+ def test_format_without_tzinfo(self): # noqa
"""Format times without timezone info"""
dt = self.sometime_univ
auckland = pytz.timezone('Pacific/Auckland')
est = pytz.timezone('EST')
ams = pytz.timezone('Europe/Amsterdam')
- self.assertEquals(times.format(dt, auckland), '2012-02-02T00:56:31+13:00')
+ self.assertEquals(times.format(dt, auckland),
+ '2012-02-02T00:56:31+13:00')
self.assertEquals(times.format(dt, ams), '2012-02-01T12:56:31+01:00')
self.assertEquals(times.format(dt, est), '2012-02-01T06:56:31-05:00')
@@ -182,11 +186,11 @@ class TestTimes(TestCase):
"""Format refuses local time input"""
auckland = pytz.timezone('Pacific/Auckland')
with self.assertRaises(ValueError):
- times.format(self.sometime_in_amsterdam, auckland)
+ times.format(self.time_in_ams, auckland)
# from/to unix and back
- def test_convert_between_unix_times(self):
+ def test_convert_between_unix_times(self): # noqa
"""Can convert UNIX time to universal time and back."""
given_unix = 1328257004.456 # as returned by time.time()
self.assertEquals(
@@ -199,4 +203,3 @@ class TestTimes(TestCase):
times.from_unix(times.to_unix(given_dt)),
given_dt
)
-