FEA-Bench / testbed /falconry__falcon /tests /test_options.py
hc99's picture
Add files using upload-large-folder tool
fc0f7bd verified
raw
history blame
1.11 kB
import ddt
from falcon.request import RequestOptions
import falcon.testing as testing
@ddt.ddt
class TestRequestOptions(testing.TestBase):
def test_option_defaults(self):
options = RequestOptions()
self.assertFalse(options.keep_blank_qs_values)
self.assertFalse(options.auto_parse_form_urlencoded)
self.assertTrue(options.auto_parse_qs_csv)
self.assertTrue(options.strip_url_path_trailing_slash)
@ddt.data(
'keep_blank_qs_values',
'auto_parse_form_urlencoded',
'auto_parse_qs_csv',
'strip_url_path_trailing_slash',
)
def test_options_toggle(self, option_name):
options = RequestOptions()
setattr(options, option_name, True)
self.assertTrue(getattr(options, option_name))
setattr(options, option_name, False)
self.assertFalse(getattr(options, option_name))
def test_incorrect_options(self):
options = RequestOptions()
def _assign_invalid():
options.invalid_option_and_attribute = True
self.assertRaises(AttributeError, _assign_invalid)