-
Notifications
You must be signed in to change notification settings - Fork 0
Did a level 1_5 tests. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from functions.level_1_5.five_replace_word import replace_word | ||
|
|
||
| def test__replace_word__starts_with_case_irrelevant(): | ||
| assert replace_word('the big black car', 'big', 'Black') == 'the Black black car' | ||
|
|
||
|
|
||
| def test__replace_word__if_replace_word_not_find_in_text(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Можно еще явнее описать тест в названии, |
||
| assert replace_word('the big black car', 'red', 'small') == 'the big black car' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from functions.level_1_5.four_sentiment import check_tweet_sentiment | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 кейсы найдены хорошие. |
||
|
|
||
| def test__check_tweet_sentiment__with_only_good_words(): | ||
| text = 'This text with only good words' | ||
| good_words = ['good', 'best', 'perfect'] | ||
| bad_words = ['bad', 'scary', 'terrible'] | ||
| assert check_tweet_sentiment(text, good_words, bad_words) == 'GOOD' | ||
|
|
||
|
|
||
| def test__check_tweet_sentiment__with_only_bad_words(): | ||
| text = 'This text with only bad words' | ||
| good_words = ['good', 'best', 'perfect'] | ||
| bad_words = ['bad', 'scary', 'terrible'] | ||
| assert check_tweet_sentiment(text, good_words, bad_words) == 'BAD' | ||
|
|
||
|
|
||
| def test__check_tweet_sentiment__with_equal_good_and_bad_words(): | ||
| text = 'This text with good and bad words' | ||
| good_words = ['good', 'best', 'perfect'] | ||
| bad_words = ['bad', 'scary', 'terrible'] | ||
| assert check_tweet_sentiment(text, good_words, bad_words) == None | ||
|
|
||
|
|
||
| def test__check_tweet_sentiment__without_good_and_bad_words(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 во всех тестах этого модуля не хватает глагола в названии, описывающего поведение, описывается факт, что на входе, но не поведение
|
||
| text = 'This text without needed words' | ||
| good_words = ['good', 'best', 'perfect'] | ||
| bad_words = ['bad', 'scary', 'terrible'] | ||
| assert check_tweet_sentiment(text, good_words, bad_words) == None | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| from functions.level_1_5.one_median import get_median_value | ||
| import pytest | ||
|
|
||
|
|
||
| def test__get_median_value__with_empty_items(): | ||
| assert get_median_value([]) == None | ||
|
|
||
|
|
||
| @pytest.mark.xfail | ||
| def test__get_median_value__with_even_len_of_items(): | ||
| assert get_median_value([2, 1, 4, 3]) == 1 | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason='Incorrect calculation') | ||
| def test__get_median_value__with_more_even_items(): | ||
| assert get_median_value([2, 1, 4, 3, 5, 6]) == 3 | ||
|
|
||
|
|
||
| @pytest.mark.xfail(reason='Incorrect calculation') | ||
| def test__get_median_value__with_odd_len_of_items(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 не хватает глагола, описывающего поведение |
||
| assert get_median_value([1, 3, 6, 8, 9]) == 6 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from functions.level_1_5.three_first import first | ||
| import pytest | ||
|
|
||
|
|
||
| def test__first__with_items(): | ||
| assert first([5, 7, 1, 15]) == 5 | ||
|
|
||
|
|
||
| def test__first__with_empty_items_and_default_is_not_set(): | ||
| with pytest.raises(AttributeError): | ||
| first([]) | ||
|
|
||
|
|
||
| def test__first__with_empty_items_and_default_is_none(): | ||
| assert first([], None) == None | ||
|
|
||
|
|
||
| def test__first__with_empty_items_and_default_is_int(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 есть то что на входе в названии, но не отражено поведение, что мы ожидаем увидеть |
||
| assert first([], 0) == 0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from functions.level_1_5.two_square_equation import solve_square_equation | ||
| import pytest | ||
|
|
||
|
|
||
| def test__solve_square_equation__if_discriminant_is_negative(): | ||
| assert solve_square_equation(1.0, 1.0, 1.0) == (None, None) | ||
|
|
||
|
|
||
| def test__solve_square_equation__if_discriminant_is_positive(): | ||
| assert solve_square_equation(1.0, -3.0, 2.0) == (1.0, 2.0) | ||
|
|
||
|
|
||
| @pytest.mark.xfail | ||
| def test__solve_square_equation__if_discriminant_is_equal_to_zero(): | ||
| assert solve_square_equation(1.0, -2.0, 1.0) == (1, None) | ||
|
|
||
|
|
||
| def test__solve_square_equation__if_square_coefficient_is_equal_to_zero(): | ||
| assert solve_square_equation(0, 2.0, 1) == (-0.5, None) | ||
|
|
||
|
|
||
| def test__solve_square_equation__if_square_coefficient_and__linear_coefficients_are_equal_to_zero(): | ||
| assert solve_square_equation(0, 0, 1) == (None, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 если case irrelevant - то это
replace_word('the big black car', 'Big', 'Black'), искомое слово ищется без учета регистра букв