Skip to content

Commit

Permalink
fix(api_helpers): re-add falcon.api_helpers (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Apr 12, 2021
1 parent f610ea4 commit 9338511
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/_newsfragments/1902.rst
@@ -0,0 +1,2 @@
Re-add ``api_helpers`` module that was renamed ``app_helpers``.
This module is considered deprecated, and will be removed in a future Falcon version.
7 changes: 7 additions & 0 deletions falcon/api_helpers.py
@@ -0,0 +1,7 @@
from .app_helpers import * # NOQA

# TODO deprecate
# import warnings
# from .util.deprecation import DeprecatedWarning

# warnings.warn('The api_helpers module was renamed to app_helpers.', DeprecatedWarning)
7 changes: 7 additions & 0 deletions falcon/app_helpers.py
Expand Up @@ -22,6 +22,13 @@
from falcon.errors import CompatibilityError
from falcon.util.sync import _wrap_non_coroutine_unsafe

__all__ = (
'prepare_middleware',
'prepare_middleware_ws',
'default_serialize_error',
'CloseableStreamIterator'
)


def prepare_middleware(middleware, independent_middleware=False, asgi=False):
"""Check middleware interfaces and prepare the methods for request handling.
Expand Down
26 changes: 25 additions & 1 deletion tests/test_deprecations.py
@@ -1,6 +1,30 @@
from falcon import request_helpers, stream
import pytest

from falcon import app_helpers, request_helpers, stream

# from _util import has_cython


def test_bounded_stream():
assert request_helpers.Body is stream.Body
assert request_helpers.BoundedStream is stream.BoundedStream


class TestApiHelpers:
@pytest.mark.filterwarnings('ignore:The api_helpers')
def test_imports(self):
from falcon import api_helpers

for name in app_helpers.__all__:
assert getattr(api_helpers, name) is getattr(app_helpers, name)

# TODO enable test of deprecation
# @pytest.mark.skipif(has_cython, reason='Reloading modules on Cython does not work')
# def test_warning(self):
# import importlib

# from falcon.util.deprecation import DeprecatedWarning

# with pytest.warns(DeprecatedWarning, match='The api_helpers'):
# from falcon import api_helpers
# importlib.reload(api_helpers)

0 comments on commit 9338511

Please sign in to comment.