Skip to content

Comments

diplom 1#4

Open
ShamilovR wants to merge 1 commit intomasterfrom
diplom_1
Open

diplom 1#4
ShamilovR wants to merge 1 commit intomasterfrom
diplom_1

Conversation

@ShamilovR
Copy link
Owner

No description provided.

price = 42.0
bun = Bun(name, price)
assert bun.get_name() == name
assert bun.get_price() == price
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: здесь и далее: проверка каждого атрибута или метода должна производиться отдельно. В случае паления на первом assert, вторая проверка не будет выполнена.


def test_init_bun_with_empty_data(self):
has_error = False
try:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: использование try/except для тестовых сценариев недопустимо. Для проверки исключений можно использовать pytest.raises

Comment on lines +55 to +57
assert len(list(re.finditer(bun.get_name(), receipt))) == 2
assert f"{str(ingredient.get_type()).lower()} {ingredient.get_name()}" in receipt
assert f'Price: {burger.get_price()}' in receipt
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: проверка вхождения подстроки в полной строке не дает гарантии, что полная строка составлена верно. В данном случае нужно либо собрать полную строку в рамках тестового сценария, либо использовать захардкоженную.

Comment on lines +29 to +31
ingredient_1 = Ingredient("test1", "test1", 42.0)
ingredient_2 = Ingredient("test2", "test2", 43.0)
ingredient_3 = Ingredient("test3", "test3", 44.0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно лучше: это создание тестовых объектов повторяется из теста в тест, а значит это предусловие, его следовало описать в фикстуре

Comment on lines +7 to +9
type = "test type"
name = "test ingredient"
price = 42.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно лучше: тестовые данные стоит хранить отдельно в data модуле, так поддерживать и переиспользовать будет проще, в тестах и тестовых классах их держать не стоит

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants