File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 22# -*- coding: utf-8 -*-
33import pytest
44
5+ from textwrap import dedent
56from flask import Flask , jsonify
67
78
9+ pytest_plugins = 'pytester'
10+
11+
812@pytest .fixture
913def app ():
1014 app = Flask (__name__ )
@@ -19,3 +23,28 @@ def ping():
1923 return jsonify (ping = 'pong' )
2024
2125 return app
26+
27+
28+ @pytest .fixture
29+ def appdir (testdir ):
30+ app_root = testdir .tmpdir
31+ test_root = app_root .mkdir ('tests' )
32+
33+ def create_test_module (code , filename = 'test_app.py' ):
34+ f = test_root .join (filename )
35+ f .write (dedent (code ), ensure = True )
36+ return f
37+
38+ testdir .create_test_module = create_test_module
39+
40+ testdir .create_test_module ('''
41+ import pytest
42+
43+ from flask import Flask
44+
45+ @pytest.fixture
46+ def app():
47+ app = Flask(__name__)
48+ return app
49+ ''' , filename = 'conftest.py' )
50+ return testdir
You can’t perform that action at this time.
0 commit comments