You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
contentsoftest_foo.pyimportpytestimportrequests@pytest.fixturedefdata(api_url): # probably a good idea to rename your fixture to a api_response or change what fixture returns.returnrequests.get(api_url)
deftest_bar(data):
print(data.text)
# below you are not testing data, but merely checking that response object is not NoneassertdataisnotNone# this will always pass# you probably want to test status code and response contentassertdata.status_code==200assertdata.json()
# Run the tests: pytest -vvv --api_version v24 test_foo.py
# In test_foo.py you don't need to import api_url. # Please notice that the api_url fixture from conftest.py is used in fixture data.importrequests@pytest.fixturedefdata(api_url):
returnrequests.request("GET", api_url)
test_bar(data):
assertdataisnotNone