Skip to content

Commit

Permalink
Fix tests for tornado+pytest issue (#943)
Browse files Browse the repository at this point in the history
* Minor mypy fix: adjust location of ignore

For multiline assignments, ignores now go on the value expression, not
the trailing paren.

* Fix runTest issue on tornado + pytest

This is a workaround which resolves #941 for now.
  • Loading branch information
sirosen authored May 21, 2024
1 parent 8472939 commit 9b3cd2f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/webargs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
__version__ = importlib.metadata.version("webargs")
__parsed_version__ = Version(__version__)
__version_info__: tuple[int, int, int] | tuple[int, int, int, str, int] = (
__parsed_version__.release
) # type: ignore[assignment]
__parsed_version__.release # type: ignore[assignment]
)
if __parsed_version__.pre:
__version_info__ += __parsed_version__.pre # type: ignore[assignment]
__all__ = ("ValidationError", "fields", "missing", "validate")
22 changes: 19 additions & 3 deletions tests/test_tornadoparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import tornado.httpserver
import tornado.httputil
import tornado.ioloop
import tornado.testing
import tornado.web
from tornado.testing import AsyncHTTPTestCase

from webargs import fields, missing
from webargs.core import json, parse_json
Expand All @@ -20,6 +20,22 @@
use_kwargs,
)


class BaseAsyncTestCase(tornado.testing.AsyncHTTPTestCase):
# this isn't a real test case itself
__test__ = False

# Workaround for https://github.com/pytest-dev/pytest/issues/12263.
#
# this was suggested by one of the pytest maintainers while a patch
# for Tornado is pending
#
# we may need it even after the patch, since we want to support testing on
# older Tornado versions until we drop support for them
def runTest(self):
pass


name = "name"
value = "value"

Expand Down Expand Up @@ -460,7 +476,7 @@ def get(self, id, args):
)


class TestApp(AsyncHTTPTestCase):
class TestApp(BaseAsyncTestCase):
def get_app(self):
return echo_app

Expand Down Expand Up @@ -528,7 +544,7 @@ def post(self, args):
)


class TestValidateApp(AsyncHTTPTestCase):
class TestValidateApp(BaseAsyncTestCase):
def get_app(self):
return validate_app

Expand Down

0 comments on commit 9b3cd2f

Please sign in to comment.