Код: Выделить всё
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 environment (such as editing configuration files) to run it.
in Working Effectively with legacy code (book).
< /code>
У меня есть функция, которая загружает zip из Интернета, а затем преобразует ее в объект Python для определенного класса.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
Что вы будете делать, чтобы написать хороший модульный тест в такой ситуации?
Подробнее здесь: https://stackoverflow.com/questions/746 ... without-ch