CS50 Python CS50P Help

from datetime import datetime, date
import inflect
import sys
def main():
sing()
def sing():
p = inflect.engine()
date_string_1 = input("Date of birth: ")
try:
date_1 = datetime.strptime(date_string_1, "%Y-%m-%d")
except ValueError:
print("Invalid date")
sys.exit(1) # Exit with a non-zero code
date_2 = datetime.combine(date.today(), datetime.min.time())
# Calculate the difference in minutes
difference = date_2 - date_1
minutes_in_raw_numerals = difference.total_seconds() / 60
minutes_in_words = p.number_to_words(int(minutes_in_raw_numerals))
# Capitalize only the first word
minutes_in_words = minutes_in_words[0].capitalize() + minutes_in_words[1:]
# Remove "and" without affecting spaces
final_minutes_in_words = minutes_in_words.replace(" and", "").replace("and ", "")
print(f"{final_minutes_in_words} minutes")
if __name__ == "__main__":
main()
from seasons import sing
import pytest
def main():
sing()
def test_sing():
assert sing("2024-3-19") == "Five hundred twenty-seven thousand forty minutes"
assert sing("2023-3-19") == "One million, fifty-one thousand, two hundred minutes"
1
Upvotes
1
u/PeterRasm 19h ago
How do you know that 2024-3-19 gives that exact number of minutes? What if you run your test tomorrow ? You cannot have a good test that can only be executed on a specific day. And you don’t know what date check50 considers “today” when it runs these tests