Ejemplo n.º 1
0
	def test_max_operand_not_iterable(self):
		"""
		Tests return of a TypeError if passing non-datetime.datetime objects
		"""
		x1 = 1

		with self.assertRaises(TypeError):
			dts.max(x1)
Ejemplo n.º 2
0
	def test_max_invalid_operant_object(self):
		"""
		Tests return of a TypeError if passing non-datetime.datetime objects
		"""
		x1 = ['not a datetime.datetime']

		with self.assertRaises(TypeError):
			dts.max(x1)
Ejemplo n.º 3
0
	def test_max_empty(self):
		"""
		Tests return of IndexError when passing a zero-length list
		"""
		n1 = list()

		with self.assertRaises(IndexError):
			dts.max(n1)
Ejemplo n.º 4
0
	def test_max_tzs(self):
		"""
		Tests max for a list of non-naive datetimes 
		"""
		london = dt.datetime(2014, 1, 1, 12, 0, 0, tzinfo=pytz.timezone('Europe/London'))
		nyc = dt.datetime(2014, 1, 1, 12, 0, 0, tzinfo=pytz.timezone('America/New_York'))
		singapore = dt.datetime(2014, 1, 1, 12, 0, 0, tzinfo=pytz.timezone('Asia/Singapore'))
		t3 = [london, nyc, singapore]

		self.assertEquals(dts.max(t3), nyc)
Ejemplo n.º 5
0
	def test_max_naive(self):
		"""
		Tests max for a list of naive datetimes 
		"""
		naive_1 = dt.datetime(2015, 9, 10, 12, 0, 0)
		naive_2 = dt.datetime(2014, 9, 10, 12, 0, 0)
		naive_3 = dt.datetime(2017, 9, 10, 12, 0, 0)
		naive_4 = dt.datetime(2016, 9, 10, 12, 0, 0)
		n4 = [naive_1, naive_2, naive_3, naive_4]

		self.assertEquals(dts.max(n4), naive_3)