Skip to content

Commit

Permalink
Avoid calling the app fixture directly
Browse files Browse the repository at this point in the history
This behaviour is deprecated and is to be removed in pytest 4.
  • Loading branch information
prophile committed Oct 9, 2018
1 parent ce00c65 commit 95dcbe9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions routemaster/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,24 @@ def json(self):
return json.loads(self.data)


def get_test_app(**kwargs):
"""Instantiate an app with testing parameters."""
return TestApp(Config(
state_machines=kwargs.get('state_machines', TEST_STATE_MACHINES),
database=kwargs.get('database', TEST_DATABASE_CONFIG),
logging_plugins=kwargs.get('logging_plugins', [
LoggingPluginConfig(
dotted_path='routemaster.logging:PythonLogger',
kwargs={'log_level': 'DEBUG'},
),
]),
))


@pytest.fixture()
def client(custom_app=None):
"""Create a werkzeug test client."""
_app = app() if custom_app is None else custom_app
_app = get_test_app() if custom_app is None else custom_app
server.config.app = _app
_app.logger.init_flask(server)
return Client(wrap_application(_app, server), TestClientResponse)
Expand All @@ -276,22 +290,13 @@ def client(custom_app=None):
@pytest.fixture()
def app(**kwargs):
"""Create an `App` config object for testing."""
return TestApp(Config(
state_machines=kwargs.get('state_machines', TEST_STATE_MACHINES),
database=kwargs.get('database', TEST_DATABASE_CONFIG),
logging_plugins=kwargs.get('logging_plugins', [
LoggingPluginConfig(
dotted_path='routemaster.logging:PythonLogger',
kwargs={'log_level': 'DEBUG'},
),
]),
))
return get_test_app(**kwargs)


@pytest.fixture()
def custom_app():
"""Return the app config fixture directly so that we can modify config."""
return app
"""Return the test app generator so that we can pass in custom config."""
return get_test_app


@pytest.fixture()
Expand Down

0 comments on commit 95dcbe9

Please sign in to comment.