From 308a384152aa4ff9b37b9c856f6c5cfe14c0800d Mon Sep 17 00:00:00 2001 From: Carlos A Date: Sun, 2 Jul 2023 12:50:03 -0500 Subject: [PATCH] Reto #26 - Python --- .../python/test0n3.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Retos/Reto #26 - TESTING [Media]/python/test0n3.py diff --git a/Retos/Reto #26 - TESTING [Media]/python/test0n3.py b/Retos/Reto #26 - TESTING [Media]/python/test0n3.py new file mode 100644 index 0000000000..5295f4c3aa --- /dev/null +++ b/Retos/Reto #26 - TESTING [Media]/python/test0n3.py @@ -0,0 +1,37 @@ +# código de la función le pertenece a @jcdm60 +# disponible en: https://github.com/mouredev/retos-programacion-2023/blob/main/Retos/Reto%20%2312%20-%20VIERNES%2013%20%5BF%C3%A1cil%5D/python/jcdm60.py + +import datetime + + +def is_friday_13(month, year): + + # Creamos un objeto datetime para el 13 del month y año indicados + date = datetime.date(year, month, 13) + + # Comprobamos si es viernes (el número 4 representa el día viernes) + if date.weekday() == 4: + return True + else: + return False + + +def test_is_friday_13(): + tests = {'input': [[4, 2022], [8, 2024], [5, 2022], [ + 9, 2024]], 'output': [False, False, True, True]} + errors = 0 + + for index, test in enumerate(tests['input']): + resp = is_friday_13(test[0], test[1]) + expected = tests['output'][index] + if resp != expected: + errors += 1 + print(f"\n\noriginal: {test}") + print(resp) + print(f"expected: {expected}") + + print( + f"\nTests{' not ' if errors != 0 else ' '}passed, {errors} errors\n") + + +test_is_friday_13()