def test_string_output_iso(self):
     self.assertEqual(dt('1850').isoformat(), '1850-01-01 00:00:00')
 def test_string_output(self):
     self.assertEqual('{}'.format(dt('2019')), '2019')
     self.assertEqual('{}'.format(dt('20190918')), '20190918')
 def test_string_output_pre1900(self):
     self.assertEqual('{}'.format(dt('1850')), '1850')
     self.assertEqual(dt('185009182359').format(precision=4), '1850091823')
 def test_init_epoch(self):
     # Make sure we're not doing platform-dependent stuff that breaks
     # outside of 1970-2038
     self.assertEqual(dt(1850), datetime.datetime(1850, 1, 1))
     self.assertEqual(dt(1850).precision, 1)
     self.assertEqual(dt(2112, 9, 18), datetime.datetime(2112, 9, 18))
     self.assertEqual(dt(2112, 9, 18).precision, 3)
     self.assertEqual(dt(datetime.datetime(1850, 1, 1), 1), dt(1850))
     self.assertEqual(dt(datetime.datetime(1850, 5, 1), 2), dt(1850, 5))
     self.assertEqual(dt(datetime.datetime(1850, 5, 18), 2), dt(1850, 5))
     self.assertEqual(dt(datetime.datetime(2112, 1, 1), 1), dt(2112))
     self.assertEqual(dt(datetime.datetime(2112, 5, 1), 2), dt(2112, 5))
     self.assertEqual(dt(datetime.datetime(2112, 5, 18), 2), dt(2112, 5))
 def test_init_coerce(self):
     self.assertEqual(dt(datetime.datetime(2019, 1, 1), 1), dt(2019))
     self.assertEqual(dt(datetime.datetime(2019, 5, 1), 2), dt(2019, 5))
     self.assertEqual(dt(datetime.datetime(2019, 5, 18), 2), dt(2019, 5))
 def test_input_list_parsing(self):
     self.assertEqual(
         dt_range.from_date_span(dt(2015), dt(2010), dt(2019), dt(2017)),
         dt_range(2010, 2019))
     self.assertEqual(dt_range(['20100201', '20190918']),
                      dt_range('20100201', '20190918'))
 def test_input_string_parsing(self):
     self.assertEqual(dt_range(2010, 2019), dt_range(dt(2010), dt(2019)))
     self.assertEqual(dt_range('20100201', '20190918'),
                      dt_range(dt(2010, 2, 1), dt(2019, 9, 18)))
 def test_init(self):
     self.assertEqual(dt(2019), datetime.datetime(2019, 1, 1))
     self.assertEqual(dt(2019).precision, 1)
     self.assertEqual(dt(2019, 9, 18), datetime.datetime(2019, 9, 18))
     self.assertEqual(dt(2019, 9, 18).precision, 3)