I have to do some testing using pytest, but I have no idea where to start. Here is piece of a code which i would like to test:
def print_url_and_id():
for item in movie_link[:100]:
print item.contents[1], "The ID of this movie is:", '"' + item.contents[1]['href'][7:16] + '"'
Could anyone tell me how it suppose to look like?
You can do something like this:
import pytest
def parametrized():
expected_results = ["movie_link_01", "movie_link_02"]
movie_link = ["movie_link_01", "movie_link_02", "movie_link_03"]
# you can define your new_movie_link list like this as you have done, but instead of
# printing it, add it to a this new_movie_link list
return [(item_1, item_2) for item_1, item_2 in zip(movie_link[:2], expected_results)]
@pytest.mark.parametrize("movie_link, expected", parametrized())
def test_parametrizer(movie_link, expected):
assert movie_link == expected
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.