Skip to content

Commit

Permalink
Ported to Python 3.3, added tox.ini and MANIFEST.in.
Browse files Browse the repository at this point in the history
  • Loading branch information
alga committed Feb 20, 2013
1 parent 911efce commit a64c1fd
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 8 deletions.
9 changes: 9 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,9 @@
include *.rst
include *.txt
include tox.ini
include bootstrap.py
include buildout.cfg

recursive-include src *

global-exclude *.pyc
21 changes: 20 additions & 1 deletion setup.py
Expand Up @@ -13,8 +13,26 @@
##############################################################################
"""zope.browserresource setup
"""
import os
import sys
from setuptools import setup, find_packages


def test_suite():
# use the zope.testrunner machinery to find all the
# test suites we've put under ourselves
from zope.testrunner.options import get_options
from zope.testrunner.find import find_suites
from unittest import TestSuite
here = os.path.abspath(os.path.dirname(sys.argv[0]))
args = sys.argv[:]
src = os.path.join(here, 'src')
defaults = ['--test-path', src]
options = get_options(args, defaults)
suites = list(find_suites(options))
return TestSuite(suites)


long_description = (open('README.txt').read() + '\n\n' +
open('CHANGES.txt').read())

Expand All @@ -39,13 +57,14 @@
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
test_suite='__main__.test_suite',

namespace_packages=['zope'],
include_package_data=True,
install_requires=['setuptools',
'zope.component>=3.8.0',
'zope.configuration',
'zope.contenttype',
'zope.contenttype>=4.0.1',
'zope.i18n',
'zope.interface',
'zope.location',
Expand Down
8 changes: 4 additions & 4 deletions src/zope/browserresource/file.py
Expand Up @@ -219,13 +219,13 @@ def GET(self):
# understand the screwy date string as a lucky side effect
# of the way they parse it).
try:
mod_since = long(mktime_tz(parsedate_tz(header)))
except:
mod_since = int(mktime_tz(parsedate_tz(header)))
except (ValueError, TypeError):
mod_since = None
if getattr(file, 'lmt', None):
last_mod = long(file.lmt)
last_mod = int(file.lmt)
else:
last_mod = 0L
last_mod = 0
if mod_since is None or last_mod <= 0 or last_mod > mod_since:
all_cache_checks_passed = False

Expand Down
6 changes: 4 additions & 2 deletions src/zope/browserresource/tests/test_directives.py
Expand Up @@ -16,8 +16,10 @@

import os
import unittest
from cStringIO import StringIO

try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
from zope import component
from zope.interface import Interface, implements, directlyProvides, providedBy

Expand Down
9 changes: 9 additions & 0 deletions src/zope/browserresource/tests/test_file.py
Expand Up @@ -16,6 +16,7 @@

import doctest
import os
import re
import unittest
import time
try:
Expand All @@ -24,6 +25,7 @@
from email.Utils import formatdate, parsedate_tz, mktime_tz

from zope.testing import cleanup
from zope.testing.renormalizing import RENormalizing
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.security.checker import NamesChecker
Expand Down Expand Up @@ -279,10 +281,17 @@ def doctest_FileResource_GET_if_none_match_and_if_modified_since():


def test_suite():
checker = RENormalizing([
# Python 3 includes module name in exceptions
(re.compile(r"zope.publisher.interfaces.NotFound"),
"NotFound"),
])

return unittest.TestSuite((
doctest.DocTestSuite(
'zope.browserresource.file',
setUp=setUp, tearDown=tearDown,
checker=checker,
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
doctest.DocTestSuite(
setUp=setUp, tearDown=tearDown,
Expand Down
5 changes: 4 additions & 1 deletion src/zope/browserresource/tests/test_icondirective.py
Expand Up @@ -14,7 +14,10 @@
"""Test Icon-Directive
"""
import os
from StringIO import StringIO
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from unittest import TestCase, main, makeSuite

from zope import component
Expand Down
8 changes: 8 additions & 0 deletions src/zope/browserresource/tests/test_resources.py
Expand Up @@ -14,9 +14,11 @@
"""Test Browser Resources
"""

import re
import doctest
import unittest
from zope.testing import cleanup
from zope.testing.renormalizing import RENormalizing

def setUp(test):
cleanup.setUp()
Expand All @@ -25,9 +27,15 @@ def tearDown(test):
cleanup.tearDown()

def test_suite():
checker = RENormalizing([
# Python 3 includes module name in exceptions
(re.compile(r"zope.publisher.interfaces.NotFound"),
"NotFound"),
])
return unittest.TestSuite((
doctest.DocTestSuite(
'zope.browserresource.resources',
setUp=setUp, tearDown=tearDown,
checker=checker,
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE),
))
8 changes: 8 additions & 0 deletions tox.ini
@@ -0,0 +1,8 @@
[tox]
envlist = py26,py27,py33

[testenv]
commands = python setup.py test -q
deps =
zope.testrunner
zope.testing

0 comments on commit a64c1fd

Please sign in to comment.