summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheron Luhn <theron@luhn.com>2014-06-04 11:18:53 -0700
committerTheron Luhn <theron@luhn.com>2014-06-04 11:18:53 -0700
commit9e0dd86bf79c7eb9a7e2a4edb66e1f668b5b96c5 (patch)
treef1493e61057dabe08af4ca103262c9d73b02ef60
parentee182e49f88a01dbd71b8bcd02c681592395cdf1 (diff)
downloadwebtest-9e0dd86bf79c7eb9a7e2a4edb66e1f668b5b96c5.tar.gz
Fix a minor misunderstanding.
-rw-r--r--webtest/app.py13
-rw-r--r--webtest/compat.py13
2 files changed, 13 insertions, 13 deletions
diff --git a/webtest/app.py b/webtest/app.py
index ec57ef0..975902b 100644
--- a/webtest/app.py
+++ b/webtest/app.py
@@ -28,7 +28,7 @@ from six.moves import http_cookiejar
from webtest.compat import urlparse
from webtest.compat import urlencode
from webtest.compat import to_bytes
-from webtest.compat import COOKIE_ESCAPE_CHAR_MAP
+from webtest.compat import escape_cookie_value
from webtest.response import TestResponse
from webtest import forms
from webtest import lint
@@ -224,7 +224,7 @@ class TestApp(object):
Sets a cookie to be passed through with requests.
"""
- value = self.escape_cookie(value)
+ value = escape_cookie_value(value)
cookie = http_cookiejar.Cookie(
version=0,
name=name,
@@ -245,15 +245,6 @@ class TestApp(object):
)
self.cookiejar.set_cookie(cookie)
- def escape_cookie(self, value):
- """
- Escapes a value so that it can be safely stored in a cookie.
-
- """
- return str(''.join(
- COOKIE_ESCAPE_CHAR_MAP.get(x, x) for x in value
- ))
-
def reset(self):
"""
Resets the state of the application; currently just clears
diff --git a/webtest/compat.py b/webtest/compat.py
index 97da957..45334b3 100644
--- a/webtest/compat.py
+++ b/webtest/compat.py
@@ -40,6 +40,17 @@ try:
except ImportError: # pragma: no cover
from ordereddict import OrderedDict # noqa
+
+def escape_cookie_value(value):
+ """
+ Escapes a value so that it can be safely stored in a cookie.
+
+ """
+ return str(''.join(
+ COOKIE_ESCAPE_CHAR_MAP.get(x, x) for x in value
+ ))
+
+
# A list of illegal characters in a cookie and the escaped equivalent.
# Taken from Python's cookie module.
COOKIE_ESCAPE_CHAR_MAP = {
@@ -106,5 +117,3 @@ COOKIE_ESCAPE_CHAR_MAP = {
'\372' : '\\372', '\373' : '\\373', '\374' : '\\374',
'\375' : '\\375', '\376' : '\\376', '\377' : '\\377'
}
-
-