Skip to content

Commit 3fa3652

Browse files
committed
Merge pull request #28 from vitalk/app-config-teardown
Use monkeypath fixture to teardown app config
2 parents 429023d + d388fc2 commit 3fa3652

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

pytest_flask/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
__version__ = "0.7.4"
4+
__version__ = "0.7.5"

pytest_flask/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def teardown():
9494

9595

9696
@pytest.fixture(autouse=True)
97-
def _configure_application(request):
97+
def _configure_application(request, monkeypatch):
9898
"""Use `pytest.mark.app` decorator to pass options to your application
9999
factory::
100100
@@ -110,7 +110,7 @@ def test_something(app):
110110
options = request.keywords.get('app', None)
111111
if options:
112112
for key, value in options.kwargs.items():
113-
app.config[key.upper()] = value
113+
monkeypatch.setitem(app.config, key.upper(), value)
114114

115115

116116
def pytest_configure(config):

tests/test_markers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
# -*- coding: utf-8 -*-
33
import pytest
44

5+
from flask import Flask
6+
7+
8+
@pytest.fixture(scope='session')
9+
def app():
10+
app = Flask(__name__)
11+
app.config['SECRET_KEY'] = '42'
12+
return app
13+
514

615
class TestAppMarker:
716

@@ -12,3 +21,6 @@ def test_not_debug_app(self, app):
1221
@pytest.mark.app(foo=42)
1322
def test_update_application_config(self, config):
1423
assert config['FOO'] == 42
24+
25+
def test_application_config_teardown(self, config):
26+
assert 'FOO' not in config

0 commit comments

Comments
 (0)