def test_valid_years(self): n_tests = 0 for y in range(1583, 2600): argv = ['', str(y)] self.assertEqual(c.main(argv), test_Pasqua.readDB(str(y))) n_tests += 1 print('Effettuati ' + str(n_tests) + ' test (con anni validi)')
def test_year_sequence(self): inputs = ['2000', 'test', '1582'] try: fake_input = inputs.pop original_raw_input = __builtins__.raw_input __builtins__.raw_input = lambda _: fake_input() with captured_output() as (out, err): main() output = out.getvalue().strip() self.assertEqual(output, '23 April 2000') finally: __builtins__.raw_input = original_raw_input
def test_easter(self): try: original_raw_input = __builtins__.raw_input __builtins__.raw_input = lambda _: '2018' with captured_output() as (out, err): main() output = out.getvalue().strip() self.assertEqual(output, '01 April 2018') __builtins__.raw_input = lambda _: '1980' with captured_output() as (out, err): main() output = out.getvalue().strip() self.assertEqual(output, '06 April 1980') finally: __builtins__.raw_input = original_raw_input
def test_2600( self ): # anno non gestito dal programma -> il risultato atteso è None argv = ['', '2600'] self.assertEqual(c.main(argv), None)
def test_1609( self): # anno che presenta una eccezione sull'algoritmo di gauss argv = ['', '1609'] self.assertEqual(c.main(argv), '19 Aprile 1609')
def test_2016(self): argv = ['', '2016'] self.assertEqual(c.main(argv), '27 Marzo 2016')
def test_2018(self): argv = ['', '2018'] self.assertEqual(c.main(argv), '1 Aprile 2018')
def test_invalid_years_2(self): argv = ['', '2600'] self.assertEqual(c.main(argv), None)
def test_invalid_years_1(self): argv = ['', '1582'] self.assertEqual(c.main(argv), None)