Add `__dict__` to the `__slots__` methods to the Request and Response classes to make it them extensible via subclassing and adding custom attributes. I have also added tests to make sure adding custom attributes do not break and raise an `AttributeError`. Fixes #785
23 lines
571 B
Python
23 lines
571 B
Python
from falcon import Request, Response
|
|
import falcon.testing as testing
|
|
|
|
|
|
class TestSlots(testing.TestBase):
|
|
|
|
def test_slots_request(self):
|
|
env = testing.create_environ()
|
|
req = Request(env)
|
|
|
|
try:
|
|
req.doesnt = 'exist'
|
|
except AttributeError:
|
|
self.fail('Unable to add additional variables dynamically')
|
|
|
|
def test_slots_response(self):
|
|
resp = Response()
|
|
|
|
try:
|
|
resp.doesnt = 'exist'
|
|
except AttributeError:
|
|
self.fail('Unable to add additional variables dynamically')
|