Skip to content

Did a level 1_5 tests.#2

Merged
Beloded1 merged 3 commits intomainfrom
feature/do_level_1_5
May 29, 2023
Merged

Did a level 1_5 tests.#2
Beloded1 merged 3 commits intomainfrom
feature/do_level_1_5

Conversation

@Beloded1
Copy link
Copy Markdown
Owner

I didn't like the test for two_square_equation. I am sure, that I could do much more, but this didn't work. That is why I wrote just two, because others didn't work properly. Also I spent much time for one_median tests, but it conclude bag in themself.

@@ -0,0 +1,10 @@
from functions.level_1_5.two_square_equation import solve_square_equation

def test_solve_square_equation_if_discriminant_is_negatibe():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

def test_solve_square_equation_if_discriminant_is_negatibe():
assert solve_square_equation(1.0, 1.0, 1.0) == (None, None)

def test_solve_square_equation_if_discriminant_is_positive():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 наименования у тестов должны быть test__method__behavior

Comment thread tests/level_1_5/test_one_median.py Outdated

def test_get_median_value_with_odd_len_of_items():
items = [1, 3, 6, 8, 9, 10]
assert get_median_value(items) == 9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 лучше сделать этот тест ванлайнером, и передать параметры items=[1, 3, ...] как kwargs

Comment thread tests/level_1_5/test_one_median.py Outdated
@@ -0,0 +1,13 @@
from functions.level_1_5.one_median import get_median_value

def test_get_median_value_with_empty_items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 тестируем кейс на пустой входной список элементов

Comment thread tests/level_1_5/test_two_square_equation.py Outdated
Comment thread tests/level_1_5/test_three_first.py Outdated
items = [5, 7, 1, 15]
assert first(items) == 5

def test_first_with_empty_items_and_default_is_NOT_SET():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 в названиях функциях нельзя CAPS

Comment thread tests/level_1_5/test_three_first.py Outdated

def test_first_with_empty_items_and_default_is_NOT_SET():
items = []
default = "NOT_SET"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 default есть, но не используется, мне кажется тут one liner бы зашел

Comment thread tests/level_1_5/test_three_first.py Outdated
with pytest.raises(AttributeError):
first(items)

def test_first_with_empty_items_and_default_is_None():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 капс в названии

Comment thread tests/level_1_5/test_three_first.py Outdated
def test_first_with_empty_items_and_default_is_None():
items = []
default = None
assert first(items, default) == None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 oneliner заходит отлично

Comment thread tests/level_1_5/test_three_first.py Outdated
def test_first_with_empty_items_and_default_is_int():
items = []
default = 0
assert first(items, default) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 замени на ванлайнер

@Beloded1 Beloded1 merged commit 468d621 into main May 29, 2023
@Beloded1 Beloded1 deleted the feature/do_level_1_5 branch May 29, 2023 10:09
Copy link
Copy Markdown

@vppuzakov vppuzakov left a comment

Choose a reason for hiding this comment

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

👍 в целом сами тесты оформлены отлично, тест кейсы найдены хорошие. Считаю что можно смержить и в следующих ПРах вернутся порефачить.

💡 во всех тестах как будто не хватает глагола в названии описывающего поведение, есть только факты того что передается на вход.

Это уже неплохо, но вот мне чего то не хватило из названий чтобы понять тестируемое поведение. То есть да вот мы тестим функцию когда на входе такие-то значения, а какое поведение ожидаем то - в названии не видно.

Типо функция вернет true, выкинет ошибку, вернет первый элемент из списка, строку без замен, строку с заменненным словом.

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'
Copy link
Copy Markdown

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'), искомое слово ищется без учета регистра букв

assert replace_word('the big black car', 'big', 'Black') == 'the Black black car'


def test__replace_word__if_replace_word_not_find_in_text():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Можно еще явнее описать тест в названии, test__replace_word__unchanged_when_replace_word_not_found_in_text

assert check_tweet_sentiment(text, good_words, bad_words) == None


def test__check_tweet_sentiment__without_good_and_bad_words():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 во всех тестах этого модуля не хватает глагола в названии, описывающего поведение, описывается факт, что на входе, но не поведение

test__check_tweet_sentiment__return_none_when_no_good_and_bad_words_found



@pytest.mark.xfail(reason='Incorrect calculation')
def test__get_median_value__with_odd_len_of_items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 не хватает глагола, описывающего поведение

assert first([], None) == None


def test__first__with_empty_items_and_default_is_int():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 есть то что на входе в названии, но не отражено поведение, что мы ожидаем увидеть

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