Skip to content

Commit

Permalink
Port to Python 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Mar 25, 2013
1 parent 9054a21 commit 34b17f6
Show file tree
Hide file tree
Showing 12 changed files with 663 additions and 103 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- 2.6
- 2.7
- 3.3
install:
- pip install . --use-mirrors
script:
Expand Down
12 changes: 11 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ CHANGES
3.0.0 (unreleased)
==================

- Nothing changed yet.
- Added support for Python 3.3. At least for ``z3c.etestbrowser.wsgi``
and ``z3c.etestbrowser.browser``. ``z3c.etestbrowser.testing`` also
supports Python 3 by itself, but it depends on ``zope.app.testing``, which
doesn't.

- Backwards compatibility note: ``ExtendedTestBrowser.pretty_print()`` now
considers `` `` to be a whitespace character and collapses it into a
simple space.


2.0.0 (2011-10-13)
Expand All @@ -23,6 +30,7 @@ CHANGES
equality with ``zope.testbrowser`` but kept ``ExtendedTestBrowser`` for
backwards compatibility.


1.5.0 (2010-08-22)
==================

Expand All @@ -48,6 +56,7 @@ CHANGES

- Added doctest to `long_description` to show up on pypi.


1.3.0 (2009-07-23)
==================

Expand All @@ -56,6 +65,7 @@ CHANGES
- Fixed bug with `normalized_contents` which would break the `open` function
of test browser if content wasn't parsable as HTML/XML.


1.2.0 (2008-05-29)
==================

Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
"""Setup for z3c.etestbrowser package."""

import os
import ConfigParser
from setuptools import setup, find_packages

try:
from ConfigParser import ConfigParser
except ImportError:
# Python 3.x
from configparser import ConfigParser

def here(*rnames):
return os.path.join(os.path.dirname(__file__), *rnames)

Expand All @@ -25,7 +30,7 @@ def read(*rnames):
return f.read()

def get_test_requires():
parser = ConfigParser.ConfigParser()
parser = ConfigParser()
parser.read([here('tox.ini')])
return parser.get('testenv', 'deps')

Expand All @@ -41,8 +46,6 @@ def get_test_requires():
+ '\n\n' +
read('src', 'z3c', 'etestbrowser', 'README.txt')
+ '\n\n' +
read('src', 'z3c', 'etestbrowser', 'wsgi.txt')
+ '\n\n' +
read('src', 'z3c', 'etestbrowser', 'over_the_wire.txt')
+ '\n\n' +
read('CHANGES.txt')
Expand All @@ -56,6 +59,7 @@ def get_test_requires():
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError, e:
except ImportError as e:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
26 changes: 13 additions & 13 deletions src/z3c/etestbrowser/README.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Extended testbrowser
--------------------

This package provides some extensions to Zope 3's testbrowser. It is intended
for extensions that have dependencies that we do not want to rely on in the
Zope 3 core e.g. lxml.
This package provides some extensions to ``zope.testbrowser``. These are not
included in the core because they have extra dependencies, such as ``lxml``.


Requirements
Expand All @@ -23,10 +22,11 @@ and related XML technologies.

Example:

>>> from z3c.etestbrowser.testing import ExtendedTestBrowser
>>> browser = ExtendedTestBrowser()
>>> from z3c.etestbrowser.wsgi import Browser
>>> browser = Browser(wsgi_app=wsgi_app)
>>> browser.handleErrors = False
>>> browser.open("http://localhost/")
>>> print browser.contents
>>> print(browser.contents)
<!DOCTYPE ...>
...
</html>
Expand Down Expand Up @@ -60,8 +60,8 @@ contains a German umlaut:

>>> browser.xml_strict = False
>>> browser.open('http://localhost/lxml.html')
>>> browser.etree.xpath("//span")[0].text
u'K\xfcgelblitz.'
>>> print(ascii(browser.etree.xpath("//span")[0].text))
'K\xfcgelblitz.'

Invalid XML/HTML responses
++++++++++++++++++++++++++
Expand All @@ -88,7 +88,7 @@ Sometimes a normal `print` of the browsers contents is hard to read for
debugging:

>>> browser.open('http://localhost/')
>>> print browser.contents
>>> print(browser.contents)
<!DOCTYPE html ...
...Name...Title...Created...Modified...

Expand All @@ -97,9 +97,9 @@ the HTML (using htmllib internally):

>>> browser.pretty_print()
@import url(http://localhost/@@/zope3_tablelayout.css); User: Fallback
unauthenticated principal [Login][1] (image)[2] Location:...[top][3] /
unauthenticated principal [Login][1] (image)[2] Location: [top][3] /
Navigation
Loading... ... Name Title Created Modified ...
Loading... Name Title Created Modified

HTML/XML normalization
~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -109,7 +109,7 @@ testing examples with HTML or XML a bit easier when unimportant details like
whitespace are changing:

>>> browser.open('http://localhost/funny.html')
>>> print browser.contents
>>> print(browser.contents)
<html>
<head>
<title>Foo</title>
Expand All @@ -124,7 +124,7 @@ whitespace are changing:

versus

>>> print browser.normalized_contents
>>> print(browser.normalized_contents)
<html>
<head>
<title>Foo</title>
Expand Down
Loading

0 comments on commit 34b17f6

Please sign in to comment.