-
Notifications
You must be signed in to change notification settings - Fork 13
unit test level 1 #3
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
base: main
Are you sure you want to change the base?
Conversation
test_code.py
Outdated
from code import chunks, flat, has_recursive_calls, parse_iso_datetime, get_image_height_in_pixels | ||
from code import if_logs_has_any_of_commands, extract_all_constants_from_ast, is_camel_case_word | ||
from code import split_camel_case_words, is_path_in_exclude_list, get_full_class_name, max_with_default | ||
from code import is_python_class_name |
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.
предложение: Мне кажется, что тут можно все объединить from code import (.......)
test_code.py
Outdated
from code import is_python_class_name | ||
|
||
|
||
def test_chunk_iteration(): |
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.
nitpick : Мы же используем pytest? Почему бы везде для простоты потом добавление вариантов тестов не применять декаратор pytest.mark.parametrize( ' ' ) . Намного проще добавлять потом варианты для тестирования
test_code.py
Outdated
('https://via.placeholder.com/140x100', 100), | ||
] | ||
) | ||
def test_get_image_height_in_pixels(image_url, expected): |
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.
А если сайт - перестанет работать, или в нем поменяется принцип работы? Тогда тест провалится.
Советую посмотреть Mocking in pytest. Когда мы подменяем функцию во время тестирования
test_code.py
Outdated
'word, expected', | ||
[ | ||
('SuperClass', True), | ||
('nonameclass', False) |
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.
предложение: Я бы в тестах добавлял бы проверку пустых строк. Рассматрел крайние случаи
test_code.py
Outdated
'camel_cased_word, expected', | ||
[ | ||
('SuperMegaClass', ['super', 'mega', 'class']), | ||
('userName', ['user', 'name']) |
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.
suggestion: Может проверить на крайние случаи: на пустую строку или строку, где все буквы маленькие
test_code.py
Outdated
|
||
|
||
def test_get_full_class_name(): | ||
class SomeClass(): |
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.
suggestion: Я бы вынес этот класс в conftest.py а потом бы импортировал бы сюда и использовал бы в декораторе сравнение примерно так... (MyTestClass(), 'tests.conftest.MyTestClass'
'items, default, expected', | ||
[ | ||
([], 1, 1), | ||
([1, 2], None, 2), |
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.
suggestion: Можно добавить на проверку букв еще)
test_code.py
Outdated
[ | ||
(['move forward'], ['move'], True), | ||
(['variable set on'], ['set'], True), | ||
(['put'], ['put'], True) |
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.
question (non-blocking): А почему не проверяешь какие либо результаты с False? Проверка что и при неправильном будет результат, который мы ожидаем.
test_code.py
Outdated
|
||
|
||
def test_parse_iso_datetime(): | ||
iso_datetime = '2021-05-24T10:34:25.518993Z' |
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.
suggestion: Для покрытия более полного кода - я бы еще добавил проверку даты без Z
test_code.py
Outdated
|
||
|
||
def test_flat(): | ||
some_list = ['hello' 'world'] |
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.
suggestion: А если список пустой? или вложенный (Список в списке?) Или с разными типами (str, int)
No description provided.