Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_upath_property_fset():
from webob.descriptors import upath_property
req = Request.blank("/")
desc = upath_property("akey")
desc.fset(req, "avalue")
assert desc.fget(req) == "avalue"
def _blankOne(self, *arg, **kw):
from webob.request import Request
return Request.blank(*arg, **kw)
def test_accept_property_fget_nil():
desc = accept_property('Accept-Charset', '14.2')
req = Request.blank('/')
assert type(desc.fget(req)) == NilAccept
def test_environ_getter_default_fset_none():
from webob.descriptors import environ_getter
req = Request.blank("/")
desc = environ_getter("akey", default="the_default")
desc.fset(req, "baz")
desc.fset(req, None)
assert "akey" not in req.environ
def test_fdel_header_key_in_environ(self):
request = Request.blank('/', environ={'HTTP_ACCEPT_LANGUAGE': 'es'})
property_ = accept_language_property()
property_.fdel(request=request)
assert isinstance(request.accept_language, AcceptLanguageNoHeader)
assert 'HTTP_ACCEPT_LANGUAGE' not in request.environ
def test_limited_length_file_repr():
req = Request.blank('/', POST='x')
req.body_file_raw = 'dummy'
req.is_body_seekable = False
eq(repr(req.body_file.raw), "")
def test_accept_property_fget():
desc = accept_property('Accept-Charset', '14.2')
req = Request.blank('/', environ={'envkey': 'envval'})
desc.fset(req, 'val')
assert desc.fget(req).header_value == 'val'
def test_converter_delete():
from webob.descriptors import converter
from webob.descriptors import environ_getter
from webob.descriptors import parse_int_safe
from webob.descriptors import serialize_int
req = Request.blank("/")
desc = converter(
environ_getter("CONTENT_LENGTH", "666", "14.13"),
parse_int_safe,
serialize_int,
"int",
)
with pytest.raises(KeyError):
desc.fdel(req)
def disconnect(self):
# Shutdown the server:
(Request
.blank("http://0.0.0.0:%s/shutdown" % self.port)
.get_response())
self.server_process.join()