-
-
Notifications
You must be signed in to change notification settings - Fork 941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(testing): Add TestClient class and a pytest example #862
Conversation
@@ -16,23 +16,51 @@ | |||
|
|||
This package contains various test classes and utility functions to | |||
support functional testing for both Falcon-based apps and the Falcon | |||
framework itself:: | |||
framework itself. Both unittest-style and pytest-style tests are | |||
supported:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please carefully review the example code below for correctness. Thanks!
Current coverage is 100% (diff: 100%)@@ master #862 diff @@
====================================
Files 30 30
Lines 1867 1875 +8
Methods 0 0
Messages 0 0
Branches 305 305
====================================
+ Hits 1867 1875 +8
Misses 0 0
Partials 0 0
|
66a6898
to
80637ca
Compare
class MyTestCase(testing.TestCase): | ||
def setUp(self): | ||
super(MyTestCase, self).setUp() | ||
self.app = api.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm just missing something, but where is create()
defined? is that just hypothetical for the example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just hypothetical... let me try to add a comment or something to avoid confusion. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I tweaked this. Let me know if it makes more sense!
d65f62b
to
d7ed940
Compare
super(TestMyApp, self).setUp() | ||
self.api = app.create_api() | ||
super(MyTestCase, self).setUp() | ||
self.app = api.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to add that comment about create()
here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice catch! Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
492d795
to
6183803
Compare
Add a contextual wrapper for the simulate_* methods and a pytest example demonstrating its use. Also deprecate "api" in favor of "app" in TestCase, since these utils can work with any WSGI app (not just those that express HTTP APIs). This terminology makes TestCase more consistent with the new simulate_* functions and with TestClient. Finally, deprecate "api_class" in TestCase and update the docstring for the testing module to demonstrate a less hacky alternative for controlling the api instance type. As a bonus, this avoids having to try and alias api_class (a class variable). Partially implements falconry#16
6183803
to
a6672ee
Compare
👍 |
Add a contextual wrapper for the simulate_* methods and a pytest
example demonstrating its use.
Also deprecate "api" in favor of "app" in TestCase, since these utils
can work with any WSGI app (not just those that express HTTP APIs). This
terminology makes TestCase more consistent with the new simulate_*
functions and with TestClient.
Finally, deprecate "api_class" in TestCase and update the docstring
for the testing module to demonstrate a less hacky alternative for
controlling the api instance type. As a bonus, this avoids having to
try and alias api_class (a class variable).
Partially implements #16