Code: Select all
Unit tests run fast.
If they don’t run fast, they aren’t unit tests.
A test is not a unit test if
1. It talks to a database.
2. It communicates across a network.
3. It touches the file system.
4. You have to do special things to your [url=viewtopic.php?t=25360]environment[/url] (such as editing configuration files) to run it.
in Working Effectively with legacy code (book).
< /code>
Ich habe eine Funktion, die den Reißverschluss aus dem Internet herunterlädt und ihn dann in ein Python-Objekt für eine bestimmte Klasse konvertiert.import typing as t
def get_book_objects(date: str) -> t.List[Book]:
# download the zip with the date from the endpoint
res = requests.get(f"HTTP-URL-{date}")
# code to read the response content in BytesIO and then use the ZipFile module
# to extract data.
# parse the data and return a list of Book object
return books
Was werden Sie tun, um einen guten Unit -Test in dieser Art von Situation zu schreiben?