/usr/share/pyshared/zope/app/testing/cookieTestOne.txt is in python-zope.app.testing 3.10.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ========================
DocTest Functional Tests
========================
This file documents and tests doctest-based functional tests and basic
Zope web-application functionality.
This second DocTest, zope/app/testing/cookieTestOne.txt, has specifically
been created in order to make sure cookie information is not being saved
across a test suite. If we are saving these via a global 'http' instance,
we will see more results than those listed below. 'http' is instead
created in setUp within _prepare_doctest_keywords, rather than in the
global declarations.
Now we will run tests to ensure that cookies are not saved across doctests.
>>> from zope.app.testing import functional
>>> from zope.app.testing.tests import DummyCookiesResponse
We will create some cookie values and saved them in our 'http' value, which
is a CookieHandler() object.
>>> response = DummyCookiesResponse(dict(
... proton=dict(value='fromCookieTestOne',
... path='/foo',
... comment='rest is ignored'),
... neutron=dict(value='fromCookieTestOne')))
If 'http' is created as a global variable, then every doctest in this
suite will be saving cookies in it, and one doctest may see cookies for
another doctest. We only want two cookies in 'http' - the ones we just
created.
>>> http.saveCookies(response)
>>> len(http.cookies)
2
>>> http.cookies['proton'].OutputString()
'proton=fromCookieTestOne; Path=/foo...'
>>> http.cookies
<SimpleCookie: neutron='fromCookieTestOne' proton='fromCookieTestOne'>
>>> http.cookies['proton'] = 'fromCookieTestOne'
>>> http.cookies['proton']['path'] = '/foo'
>>> http.cookies['electron'] = 'fromCookieTestOne'
>>> http.cookies['electron']['path'] = '/foo/baz'
>>> http.cookies['neutron'] = 'fromCookieTestOne'
>>> cookieHeader = http.httpCookie('/foo/bar')
>>> parts = cookieHeader.split('; ')
>>> parts.sort()
>>> parts
['neutron=fromCookieTestOne', 'proton=fromCookieTestOne']
>>> cookieHeader = http.httpCookie('/foo/baz')
>>> parts = cookieHeader.split('; ')
>>> parts.sort()
>>> parts
['electron=fromCookieTestOne',
'neutron=fromCookieTestOne',
'proton=fromCookieTestOne']
|