Conversation
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture | ||
| def max_string(): |
There was a problem hiding this comment.
Название не супер – это не "максимальная строка", а просто длинная строка.
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture | ||
| def bank_card(): |
There was a problem hiding this comment.
Фикстура называется "банковская карта", а возвращает внезапно список из нескольких карт.
tests/conftest.py
Outdated
| def expense(): | ||
| return Expense( | ||
| amount=Decimal('1020'), | ||
| card=BankCard(last_digits='3326', owner='Nikita T.'), |
There was a problem hiding this comment.
Сделать бы фикстуру одной карты и переиспользовать её тут.
tests/conftest.py
Outdated
| date.month, | ||
| date.day, | ||
| 16, | ||
| 48 |
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture | ||
| def date_today(): |
There was a problem hiding this comment.
Префикс date_ можно удалить: и так понятно, что today – это дата.
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture | ||
| def date_tomorrow(date_today): |
tests/test_three_url_builder.py
Outdated
| [ | ||
| ('hh.ru', 'applicant/negotiations', { | ||
| 'hhtmFrom': 'employer', 'hhtmFromLabel': 'header' | ||
| }, 'hh.ru/applicant/negotiations?hhtmFrom=employer&hhtmFromLabel=header'), |
There was a problem hiding this comment.
Тут форматирование поломалось. Если такая последовательность не умещается в одну строку, разбивай в длинном варианте, чтобы у каждого элемента была своя строка:
(
'hh.ru',
'applicant/negotiations',
{'hhtmFrom': 'employer', 'hhtmFromLabel': 'header'},
'hh.ru/applicant/negotiations?hhtmFrom=employer&hhtmFromLabel=header',
),
tests/test_two_date_parser.py
Outdated
| 'date_str, time_str, expected_result', | ||
| [ | ||
| ('today', '16 : 48', pytest.lazy_fixture('date_today')), | ||
| ('tomorrow', '16 : 48', pytest.lazy_fixture('date_tomorrow')), |
There was a problem hiding this comment.
Тут у тебя получается, что фикстуры намертво завязаны на константы в этом параметрайзе: поменяешь одно и не поменяешь другое – тест сломается.
Это хороший признак того, что фикстура лишняя. Фигани объекты datetime.dateme прямо сюда, а фикстуры удали. Получится читаемее и проще.
tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture | ||
| def list_bank_cards(): |
There was a problem hiding this comment.
А тут list_ лишний. Понятно, что если bank_cards, то их несколько :)
Все названия нужно стараться сделать как можно более подробными, но без лишней/дублирующейся информации.
tests/conftest.py
Outdated
| @pytest.fixture | ||
| def list_bank_cards(): | ||
| return [ | ||
| BankCard(last_digits='3326', owner='Nikita T.'), |
There was a problem hiding this comment.
Кажется, тут можно переиспользовать фикстуру bank_card
tests/test_two_date_parser.py
Outdated
|
|
||
| def test_compose_datetime_from(): | ||
| pass | ||
| date = datetime.date.today() + datetime.timedelta(days=1) |
There was a problem hiding this comment.
Ну вот today и tomorrow я бы в фикстуры вынес – они универсальные и много где пригождаются обычно.
tests/conftest.py
Outdated
|
|
||
| @pytest.fixture | ||
| def today(): | ||
| today = datetime.date.today() |
There was a problem hiding this comment.
Кажись эта переменная лишняя, можно сразу ретурнить.
tests/conftest.py
Outdated
|
|
||
| @pytest.fixture | ||
| def yesterday(): | ||
| yesterday = datetime.date.today() + datetime.timedelta(days=1) |
There was a problem hiding this comment.
Тут бы тоже без промежуточной переменной и фикстуру тудей можно переиспользовать для красоты и простоты.
| [ | ||
| (pytest.lazy_fixture('male_verb'), pytest.lazy_fixture('female_verb'), 'male', pytest.lazy_fixture('male_verb')), | ||
| (pytest.lazy_fixture('male_verb'), pytest.lazy_fixture('female_verb'), 'female', pytest.lazy_fixture('female_verb')), | ||
| ] |
There was a problem hiding this comment.
Тут есть лишние параметры: первый, например, всегда одинаковый, второй тоже. Убери их из параметрайза.
И фикстуры я бы эти тоже удалил: они завязаны на этот тест и не очень универсальные, поэтому просто захардкодь слова тут и будет нормас.
tests/test_three_url_builder.py
Outdated
| [ | ||
| ('hh.ru', 'applicant/negotiations', | ||
| {'hhtmFrom': 'employer', 'hhtmFromLabel': 'header'}, | ||
| 'hh.ru/applicant/negotiations?hhtmFrom=employer&hhtmFromLabel=header'), |
There was a problem hiding this comment.
Форматирование всё ещё поломано: не видно, где тупл начинается, где заканчивается и что в нём есть. Я в прошлом комменте приводил пример, как правильно его можно отформатировать.
tests/test_two_date_parser.py
Outdated
| def test_compose_datetime_from(): | ||
| pass | ||
| def test_compose_datetime_from_today(today): | ||
| assert compose_datetime_from('today', '16 : 48') == datetime.datetime(today.year, today.month, today.day, 16, 48,) |
There was a problem hiding this comment.
Тут после последнего аргумента запятая лишняя, в следующем тесте тоже.
No description provided.