Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Lib/test/test_email/test_utils.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_email/test_email.py ('k') | Lib/test/test_exceptions.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import datetime
2 from email import utils
3 import unittest
4
5 class DateTimeTests(unittest.TestCase):
6
7 datestring = 'Sun, 23 Sep 2001 20:10:55'
8 dateargs = (2001, 9, 23, 20, 10, 55)
9 offsetstring = ' -0700'
10 utcoffset = datetime.timedelta(hours=-7)
11 tz = datetime.timezone(utcoffset)
12 naive_dt = datetime.datetime(*dateargs)
13 aware_dt = datetime.datetime(*dateargs, tzinfo=tz)
14
15 def test_naive_datetime(self):
16 self.assertEqual(utils.format_datetime(self.naive_dt),
17 self.datestring + ' -0000')
18
19 def test_aware_datetime(self):
20 self.assertEqual(utils.format_datetime(self.aware_dt),
21 self.datestring + self.offsetstring)
22
23 def test_usegmt(self):
24 utc_dt = datetime.datetime(*self.dateargs,
25 tzinfo=datetime.timezone.utc)
26 self.assertEqual(utils.format_datetime(utc_dt, usegmt=True),
27 self.datestring + ' GMT')
28
29 def test_usegmt_with_naive_datetime_raises(self):
30 with self.assertRaises(ValueError):
31 utils.format_datetime(self.naive_dt, usegmt=True)
32
33 def test_usegmt_with_non_utc_datetime_raises(self):
34 with self.assertRaises(ValueError):
35 utils.format_datetime(self.aware_dt, usegmt=True)
36
37 def test_parsedate_to_datetime(self):
38 self.assertEqual(
39 utils.parsedate_to_datetime(self.datestring + self.offsetstring),
40 self.aware_dt)
41
42 def test_parsedate_to_datetime_naive(self):
43 self.assertEqual(
44 utils.parsedate_to_datetime(self.datestring + ' -0000'),
45 self.naive_dt)
OLDNEW
« no previous file with comments | « Lib/test/test_email/test_email.py ('k') | Lib/test/test_exceptions.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+