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 2
2
# -*- coding: utf-8 -*-
3
3
import pytest
4
4
5
+ from textwrap import dedent
5
6
from flask import Flask , jsonify
6
7
7
8
9
+ pytest_plugins = 'pytester'
10
+
11
+
8
12
@pytest .fixture
9
13
def app ():
10
14
app = Flask (__name__ )
@@ -19,3 +23,28 @@ def ping():
19
23
return jsonify (ping = 'pong' )
20
24
21
25
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