1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
Description: remove test_cythonized_asgi.py
Author: Thomas Goirand <zigo@debian.org>
Forwarded: not-needed
Last-Update: 2022-08-30
Index: python-falcon/tests/asgi/test_cythonized_asgi.py
===================================================================
--- python-falcon.orig/tests/asgi/test_cythonized_asgi.py
+++ /dev/null
@@ -1,137 +0,0 @@
-import sys
-import time
-
-import pytest
-
-import falcon
-from falcon import testing
-import falcon.asgi
-from falcon.util import is_python_func
-
-try:
- import pyximport
-
- pyximport.install()
-except ImportError:
- pyximport = None
-
-# NOTE(kgriffs): We do this here rather than inside the try block above,
-# so that we don't mask errors importing _cythonized itself.
-if pyximport:
- from . import _cythonized # type: ignore
-
- _CYTHON_FUNC_TEST_TYPES = [
- _cythonized.nop_method,
- _cythonized.nop_method_async,
- _cythonized.NOPClass.nop_method,
- _cythonized.NOPClass.nop_method_async,
- _cythonized.NOPClass().nop_method,
- _cythonized.NOPClass().nop_method_async,
- ]
-else:
- _CYTHON_FUNC_TEST_TYPES = []
-
-from _util import disable_asgi_non_coroutine_wrapping # NOQA
-
-
-@pytest.fixture
-def client():
- return testing.TestClient(falcon.asgi.App())
-
-
-def nop_method(self):
- pass
-
-
-async def nop_method_async(self):
- pass
-
-
-class NOPClass:
- def nop_method(self):
- pass
-
- async def nop_method_async(self):
- pass
-
-
-@pytest.mark.skipif(not pyximport, reason='Cython not installed')
-@pytest.mark.parametrize('func', _CYTHON_FUNC_TEST_TYPES)
-def test_is_cython_func(func):
- assert not is_python_func(func)
-
-
-@pytest.mark.parametrize(
- 'func',
- [
- nop_method,
- nop_method_async,
- NOPClass.nop_method,
- NOPClass.nop_method_async,
- NOPClass().nop_method,
- NOPClass().nop_method_async,
- ],
-)
-def test_not_cython_func(func):
- assert is_python_func(func)
-
-
-@pytest.mark.skipif(not pyximport, reason='Cython not installed')
-def test_jsonchema_validator(client):
- with disable_asgi_non_coroutine_wrapping():
- client.app.add_route('/', _cythonized.TestResourceWithValidation())
-
- with pytest.raises(TypeError):
- client.app.add_route(
- '/wowsuchfail', _cythonized.TestResourceWithValidationNoHint()
- )
-
- client.simulate_get()
-
-
-@pytest.mark.skipif(not pyximport, reason='Cython not installed')
-def test_scheduled_jobs(client):
- resource = _cythonized.TestResourceWithScheduledJobs()
- client.app.add_route('/', resource)
-
- client.simulate_get()
- time.sleep(0.5)
- assert resource.counter['backround:on_get:async'] == 2
- assert resource.counter['backround:on_get:sync'] == 40
-
-
-@pytest.mark.skipif(not pyximport, reason='Cython not installed')
-@pytest.mark.skipif(
- sys.version_info < (3, 7),
- reason=(
- 'CPython 3.6 does not complain when you try to call loop.create_task() '
- 'with the wrong type.'
- ),
-)
-def test_scheduled_jobs_type_error(client):
- client.app.add_route(
- '/wowsuchfail', _cythonized.TestResourceWithScheduledJobsAsyncRequired()
- )
-
- # NOTE(kgriffs): Normally an unhandled exception is translated to a
- # 500 response, but since jobs aren't supposed to be scheduled until
- # we are done sending the response, we treat this as a special case
- # and allow the error to propagate out of the server. Masking this kind
- # of error would make it especially hard to debug in any case (it will
- # be hard enough as it is for the app developer).
- with pytest.raises(TypeError):
- client.simulate_get('/wowsuchfail')
-
-
-@pytest.mark.skipif(not pyximport, reason='Cython not installed')
-def test_hooks(client):
- with disable_asgi_non_coroutine_wrapping():
- with pytest.raises(TypeError):
- client.app.add_route('/', _cythonized.TestResourceWithHooksNoHintBefore())
- client.app.add_route('/', _cythonized.TestResourceWithHooksNoHintAfter())
-
- client.app.add_route('/', _cythonized.TestResourceWithHooks())
-
- result = client.simulate_get()
- assert result.headers['x-answer'] == '42'
- assert result.json == {'answer': 42}
Index: python-falcon/tests/test_cython.py
===================================================================
--- python-falcon.orig/tests/test_cython.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import io
-
-import pytest
-
-import falcon
-import falcon.util
-
-from _util import has_cython # NOQA
-
-
-class TestCythonized:
- @pytest.mark.skipif(not has_cython, reason='Cython not installed')
- def test_imported_from_c_modules(self):
- assert 'falcon/app.py' not in str(falcon.app)
-
- def test_stream_has_private_read(self):
- stream = falcon.util.BufferedReader(io.BytesIO().read, 8)
-
- if has_cython and falcon.util.IS_64_BITS:
- assert not hasattr(stream, '_read')
- else:
- assert hasattr(stream, '_read')
|