File: test_cookies_bw.py

package info (click to toggle)
python-webob 1%3A1.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,200 kB
  • ctags: 2,604
  • sloc: python: 14,014; makefile: 169
file content (28 lines) | stat: -rw-r--r-- 778 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-
from datetime import timedelta
from webob import cookies
from webob.compat import text_
from nose.tools import (eq_, assert_raises)
import unittest
from webob.compat import native_
from webob.compat import PY3

import warnings

def setup_module(module):
    cookies._should_raise = False

def teardown_module(module):
    cookies._should_raise = False

def test_invalid_cookie_space():
    with warnings.catch_warnings(record=True) as w:
        # Cause all warnings to always be triggered.
        warnings.simplefilter("always")
        # Trigger a warning.
        
        cookies._value_quote(b'hello world')

        eq_(len(w), 1)
        eq_(issubclass(w[-1].category, RuntimeWarning), True)
        eq_("ValueError" in str(w[-1].message), True)