File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ from flask import Flask
2+
3+ app = Flask (__name__ )
4+
5+
6+ @app .route ('/' )
7+ def home ():
8+ return "<h1>Hello world!</h1>"
9+
10+
11+ @app .route ('/<name>' )
12+ def name (name ):
13+ return "<h1>Hello {}!</h1>" .format (name )
14+
15+
16+ if __name__ == "__main__" :
17+ app .run (debug = True )
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+
4+ @pytest .mark .usefixtures ('client_class' )
5+ class TestCore :
6+
7+ @pytest .fixture
8+ def app (self ):
9+ from app import app
10+ return app
11+
12+ def test_get_home (self ):
13+ response = self .client .get ("/" )
14+ assert response .data .decode ('utf-8' ) == '<h1>Hello world!</h1>'
15+ assert response .status_code == 200
16+
17+ def test_get_name (self ):
18+ response = self .client .get ("/Rafael" )
19+ assert response .data .decode ('utf-8' ) == '<h1>Hello Rafael!</h1>'
20+ assert response .status_code == 200
You can’t perform that action at this time.
0 commit comments