level_2 tests#4
Conversation
vppuzakov
left a comment
There was a problem hiding this comment.
👍 на самом деле уже очень хорошие тесты, вмерживай
💡 дальше погляди по комментам и в след ПР попробуй поправить
| assert solve_square_equation(1.0, 0.1, 0.1) == (None, None) | ||
|
|
||
|
|
||
| def test__two_square_equation__no_square_coefficient(): |
There was a problem hiding this comment.
💡 тут можно было бы добавить к названию ожидаемое поведение - __return_one_root_when_no_square_coefficient
| from functions.level_2.two_square_equation import solve_square_equation | ||
|
|
||
|
|
||
| def test__two_square_equation__descriminant_less_than_zero(): |
There was a problem hiding this comment.
💡 добавить к названию - found_no_root_when_descriminant_less_than_zero
| assert solve_square_equation(0.0, 0.0, 0.1) == (None, None) | ||
|
|
||
|
|
||
| def test__two_square_equation__no_square_coefficient_and_no(): |
There was a problem hiding this comment.
💡 тут явно про название забыли поправить
| assert solve_square_equation(0.1, 5.1, 0.1) == (-50.980384612481814, -0.019615387518183702) | ||
|
|
||
|
|
||
| def test__two_square_equation__descriminant_is_zero(): # |
There was a problem hiding this comment.
💡 тут дискриминант меньше нуля, а тест такой уже есть у нас - первый в этом модуле - поэтому раз один кейс - давай объединим эти два входа с помощью parametrize
| @@ -0,0 +1,21 @@ | |||
| from functions.level_2.two_square_equation import solve_square_equation | |||
There was a problem hiding this comment.
👍 ну в целом то отличные и понятные тесты, но не хватает поведения ожидаемого - оно более важно, чем вход даже. Вход лишь дополнение к поведению, которое может и отсутствовать
do_something_when_something
| ('one two three four five six', '', ''), | ||
| ('one two three four five six', ' ', ' ') | ||
| ]) | ||
| def test__five_replace_word__no_replacement_if_no_replace_from_in_the_text(text, replace_from, replace_to): |
There was a problem hiding this comment.
👍 тут все отлично и название и параметры
| ('one two three four five six', 'one', ''), | ||
| ('one two three four five six', 'one', ' ') | ||
| ]) | ||
| def test__five_replace_word__replacement_if_replace_from_is_in_the_text(text, replace_from, replace_to): |
There was a problem hiding this comment.
👍 отличный тест
💡 поведение - глагол (не может быть существительным replacement) - используй replace, return_replaced, change_
| ('one two three four five six', 'one', ' ') | ||
| ]) | ||
| def test__five_replace_word__replacement_if_replace_from_is_in_the_text(text, replace_from, replace_to): | ||
| removed_first_word = text.split(' ', 1)[1] |
There was a problem hiding this comment.
💡 вот подготовка к тесту опасная - делает тест чуть более запутанней, может нам лучше иметь expected параметр как раз тут и не кодить в тесте - тест станет гораздо понятнее - давай так и сделаем
| assert replace_word(text, replace_from, replace_to) == f"{replace_to} {removed_first_word}" | ||
|
|
||
|
|
||
| def test__five_replace_word__replacement_without_changes_if_the_same_words_in_all_parameters(): |
There was a problem hiding this comment.
👍 тест супер во всем, понятное название, понятное тело - параметры реально ни к чему
| ('one two three four five six', 'ONE', ' '), | ||
| ('ONE two three four five six', 'one', 'seven'), | ||
| ]) | ||
| def test__five_replace_word__replacement_if_replace_from_is_in_the_text_ignore_case(text, replace_from, replace_to): |
There was a problem hiding this comment.
👍 отличный тест
💡 давай вместо жонглирования текстом внутри теста добавим expected параметр и тест станет гораздо явнее (зачем нам там код - кто будет тестить наши тесты тогда?)
No description provided.