Skip to content

Commit

Permalink
fix flask 2.2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
motion authored and nicolaiarocci committed Mar 11, 2023
1 parent b42f03a commit 1ae27fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions eve/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def close_pymongo_connection(app):
del app.media


def setup_add_url_rule(app, original_add_url_rule):
def wrapped_add_url_rule(*args, **kwargs):
original_got_first_request = app._got_first_request
app._got_first_request = False
original_add_url_rule(*args, **kwargs)
app._got_first_request = original_got_first_request
return wrapped_add_url_rule


class TestMinimal(unittest.TestCase):
"""Start the building of the tests for an application
based on Eve by subclassing this class and provide proper settings
Expand Down Expand Up @@ -482,6 +491,8 @@ def setUp(self, url_converters=None):
self.test_patch = "test_patch"
self.test_patch_url = "/%s" % self.domain[self.test_patch]["url"]

self.app.add_url_rule = setup_add_url_rule(self.app, self.app.add_url_rule)

def response_item(self, response, i=0):
if self.app.config["HATEOAS"]:
return response["_items"][i]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
INSTALL_REQUIRES = [
"cerberus>=1.1,<2.0",
"events>=0.3,<0.4",
"flask<2.2",
"flask",
"pymongo",
"simplejson>=3.3.0,<4.0",
]
Expand Down

0 comments on commit 1ae27fa

Please sign in to comment.