Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from zopefoundation/freshen
Browse files Browse the repository at this point in the history
Freshen
  • Loading branch information
jimfulton committed May 17, 2017
2 parents 7bef3cf + 9f4f8d0 commit 58e101a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 32 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
@@ -1,8 +1,9 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
install:
- pip install --upgrade setuptools>=1.4
- pip install --upgrade zc.buildout>=2.2.1
Expand Down
11 changes: 6 additions & 5 deletions bobo/setup.py
Expand Up @@ -34,11 +34,11 @@
name = name,
version = version,
author = "Jim Fulton",
author_email = "jim@zope.com",
author_email = "jim@jimfulton.info",
description = "Web application framework for the impatient",
license = "ZPL 2.1",
keywords = "WSGI",
url='http://www.python.org/pypi/'+name,
url='http://bobo.readthedocs.io',
long_description=open('README.txt').read(),
py_modules = ['bobo', 'boboserver'],
package_dir = {'':'src'},
Expand All @@ -52,12 +52,13 @@
"License :: OSI Approved :: Zope Public License",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Server",
)
),
)
6 changes: 4 additions & 2 deletions bobo/src/bobo.py
Expand Up @@ -345,8 +345,10 @@ def redirect(url, status=302, body=None,
"""
if body is None:
body = u'See %s' % url
if isinstance(url, unicode):
url = url.encode('utf-8')

# if isinstance(url, six.text_type):
# url = url.encode('utf-8')

response = webob.Response(status=status, headerlist=[('Location', url)])
response.content_type = content_type
response.unicode_body = body
Expand Down
4 changes: 2 additions & 2 deletions bobodoctestumentation/src/bobodoctestumentation/bobocalc.test
Expand Up @@ -34,10 +34,10 @@ Sample ajax application

>>> print(app.get('/add.json?value=0&input=42'))
Response: 200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
{"value": 42}

>>> print(app.get('/sub.json?value=42&input=42'))
Response: 200 OK
Content-Type: application/json; charset=UTF-8
Content-Type: application/json
{"value": 0}
Expand Up @@ -133,11 +133,11 @@ Let's publish a module with an error:
... # doctest: +ELLIPSIS
Traceback (most recent call last):
...
NameError: global name 'y' is not defined
NameError: ... 'y' is not defined
post_mortem:
...
return self.app(environ, start_response)
raised global name 'y' is not defined
raised ... 'y' is not defined

>>> time.sleep(1.1)

Expand Down
Expand Up @@ -23,7 +23,7 @@ it.
... if not d or len(d) == 1:
... print(repr(d))
... else:
... pprint.pprint(d, width=1)
... pprint.pprint(d)
... if not isinstance(partial, six.string_types):
... return
... match = bobo._compile_route(partial)
Expand All @@ -33,7 +33,7 @@ it.
... if not d or len(d) == 1:
... print(repr(d))
... else:
... pprint.pprint(d, width=1)
... pprint.pprint(d)

We give a route and a url and an optional partial march flag.
Non-partial routes must match the entire URL path. Partial matches can
Expand Down Expand Up @@ -212,7 +212,7 @@ We use resources by calling the result of calling bobo_response:
... print("Raised %s: %s" % (exc.__class__.__name__, exc,))
... except bobo.BoboException as v:
... print(v.__class__.__name__+':')
... pprint.pprint(v.__dict__, width=1)
... pprint.pprint(v.__dict__)

>>> call_resource(hi, '/foo')
request:
Expand Down
12 changes: 2 additions & 10 deletions bobodoctestumentation/src/bobodoctestumentation/main.test
Expand Up @@ -195,14 +195,14 @@ Configuration handlers
>>> import pprint
>>> def config_handler(d):
... print('handler1')
... pprint.pprint(d, width=1)
... pprint.pprint(d)

>>> bobo.testmodule1.config_handler = config_handler

>>> import pprint
>>> def config_handler(d):
... print('handler2')
... pprint.pprint(d, width=1)
... pprint.pprint(d, width=99)

>>> bobo.testmodule2.config_handler = config_handler

Expand Down Expand Up @@ -336,11 +336,3 @@ Ordering
>>> app = makeapp(bobo_resources='bobo.testmodule1')
>>> app.get('/o').text
'f3'


Automatic encoding of redirect destinations
-------------------------------------------

>>> response = bobo.redirect(u"http://www.\u0113xample.com/")
>>> response.headers["location"]
'http://www.\xc4\x93xample.com/'
11 changes: 6 additions & 5 deletions bobodoctestumentation/src/bobodoctestumentation/more.txt
Expand Up @@ -39,7 +39,7 @@ authorization::
Updated

>>> import pprint
>>> pprint.pprint(helloapp.data, width=1)
>>> pprint.pprint(helloapp.data)
{'foo': 'sometext',
'x': 'some text'}

Expand Down Expand Up @@ -664,7 +664,7 @@ Let's look at an example. First, an ``errorsample`` module::
"bad method "+method, status=405,
headerlist=[
('Allow', ', '.join(methods)),
('Content-Type', 'text/plain'),
('Content-Type', 'text/plain; charset=UTF-8'),
])

def missing_form_variable(request, method, name):
Expand Down Expand Up @@ -749,7 +749,7 @@ If we make a POST to the same URL, we'll get::

Response: 405 Method Not Allowed
Allow: GET
Content-Type: text/plain
Content-Type: text/plain; charset=UTF-8
bad method POST

.. -> expected4
Expand All @@ -775,7 +775,7 @@ that defines an class with methods for generating error responses::
"bad method "+method, status=405,
headerlist=[
('Allow', ', '.join(methods)),
('Content-Type', 'text/plain'),
('Content-Type', 'text/plain; charset=UTF-8'),
])

def missing_form_variable(self, request, method, name):
Expand All @@ -801,7 +801,8 @@ use an expression to specify the errors object.

>>> parser = configparser.ConfigParser()
>>> parser.readfp(six.StringIO(ini2))
>>> app = webtest.TestApp(bobo.Application(dict(parser.items('app:main'))))
>>> app = webtest.TestApp(bobo.Application(
... dict(parser.items('app:main'), bobo_handle_exceptions=False)))

>>> str(app.get(url1)).strip() == expected1
True
Expand Down
3 changes: 2 additions & 1 deletion bobodoctestumentation/src/bobodoctestumentation/tests.py
Expand Up @@ -12,8 +12,9 @@
#
##############################################################################

from zope.testing import doctest, setupstack, renormalizing
from zope.testing import setupstack, renormalizing
import bobo
import doctest
import manuel.capture
import manuel.codeblock
import manuel.doctest
Expand Down

0 comments on commit 58e101a

Please sign in to comment.