Как осуществить проверку с разными входными параметрами
Пытаюсь через параметризацию сделать два теста с разными входными параметрами.
post_json_video_with_text_teg_game_inGameId = {
'text': '@sokoban TEST POST VIDEO MP4',
'gameId': '2',
'inGameId': '245245'
}
post_json_video_with_text_teg = {
'text': '@sokoban TEST POST VIDEO MP4'
}
@pytest.mark.parametrize('files, data',
[(video_foot, post_json_video_with_text_teg_game_inGameId),
(video_foot, post_json_video_with_text_teg)])
def test_create_video_posts_2(files, data):
request_post_create = PostController().create_post(files=files, data=data)
teg = request_post_create['body']['text']
in_game_id = request_post_create['body']['inGameId']
game_id = request_post_create['body']['game']['id']
file_type = request_post_create['body']['files'][0]['fileType']
if request_post_create['body']['inGameId'] == '245245' and request_post_create['body']['game']['id'] == 2:
assert in_game_id == '245245'
assert game_id == 2
assert file_type == "VIDEO"
assert request_post_create['status']['statusCodeValue'] == 200
else:
assert request_post_create['status']['statusCodeValue'] == 200
and teg == '@sokoban TEST POST VIDEO MP4'
Но по всей видимости делаю, что то не так, так как проходит первый тест успешно, а второй нет
@pytest.mark.parametrize('files, data',
[(video_foot, post_json_video_with_text_teg_game_inGameId),
(video_foot, post_json_video_with_text_teg)])
def test_create_video_posts_2(files, data):
request_post_create = PostController().create_post(files=files, data=data)
> in_game_id = request_post_create['body']['inGameId']
E TypeError: 'NoneType' object is not subscriptable
Источник: Stack Overflow на русском