Question 9
Consider the two python files main.py and test_sample.py.
main.py
from flask import Flaskapp = Flask(__name__)
@app.route('/hello')def hello(): return 'Hello World'
@app.route('/home')def home(): return 'Hello Home'
if __name__ == '__main__': app.run(debug = True)test_sample.py
import pytest, requests
@pytest.fixturedef get_url_response(): response = requests.get('http://127.0.0.1:5000/hello') return response
def test_statuscode(get_url_response): assert get_url_response.status_code == 200
def test_text(get_url_response): assert get_url_response.text == 'Hello Home'Assuming main.py is running locally in the terminal. In another local terminal run “pytest” command. What will be the output of the test_sample.py file?
2 passed
1 failed 1 passed
2 failed
No tests