Permalink
Browse files

Merge branch 'feature/2.2' into develop

  • Loading branch information...
ralphbean committed Apr 16, 2013
2 parents 1214057 + 08fd64a commit 4aef579c77c62229d9f23c0018cfdeec73311514
@@ -1,10 +1,9 @@
language: python
python:
- "2.5"
- "2.6"
- "2.7"
# Someday, soon.
# - "3.2"
- "3.2"
- "3.3"
install: python setup.py install
script: python setup.py test
notifications:
@@ -2,6 +2,7 @@
release = egg_info -rDb "" sdist bdist_egg register upload
[nosetests]
where = tests
with-coverage = true
cover-package = tw2.core
cover-html = true
@@ -18,7 +18,7 @@
def get_description(fname='README.rst'):
# Adapted from PEAK-Rules' setup.py
# Get our long description from the documentation
f = file(fname)
f = open(fname, 'r')
lines = []
for line in f:
if not line.strip():
@@ -34,34 +34,39 @@ def get_description(fname='README.rst'):
_extra_genshi = ["Genshi >= 0.3.5"]
_extra_mako = ["Mako >= 0.1.1"]
_extra_jinja = ["jinja2"]
_extra_kajiki = ["kajiki"]
_extra_chameleon = ["chameleon"]
if sys.version_info[0] == 3:
_extra_kajiki = []
else:
_extra_kajiki = ["kajiki"] # Broken for py3.3
requires = [
'WebOb>=0.9.7',
'simplejson >= 2.0',
'PasteDeploy',
'speaklater',
'decorator',
'markupsafe',
'six',
]
if sys.version_info[0] == 2 and sys.version_info[1] <= 5:
requires.append('WebOb<=1.1.1')
tests_require = [
'nose',
'coverage',
'BeautifulSoup',
'FormEncode',
'strainer',
'sieve',
] + \
_extra_genshi + \
_extra_mako + \
_extra_jinja + \
_extra_kajiki + \
_extra_chameleon
if sys.version_info[0] == 2:
# Broken for py3
tests_require.append("Formencode")
if sys.version_info[0] == 2 and sys.version_info[1] <= 5:
tests_require.append('WebTest<2.0.0')
else:
@@ -96,11 +101,15 @@ def get_description(fname='README.rst'):
[tw2.widgets]
widgets = tw2.core
[paste.app_factory]
dev_server = tw2.core.middleware:make_app
[paste.filter_app_factory]
middleware = tw2.core.middleware:make_middleware
[distutils.commands]
archive_tw2_resources = tw2.core.command:archive_tw2_resources
# Is this broken for py3?
#[distutils.commands]
#archive_tw2_resources = tw2.core.command:archive_tw2_resources
""",
zip_safe=False,
@@ -1,9 +1,10 @@
"""
filling in the missing gaps in test coverage
"""
from __future__ import print_function
from unittest import TestCase
import distutils.dist
import StringIO
from six import StringIO
import sys
import os
import shutil
@@ -19,18 +20,18 @@
HAS_SKIP = sys.version_info[0] == 2 and sys.version_info[1] == 7
class StdOut(StringIO.StringIO):
class StdOut(StringIO):
def __init__(self,stdout):
self.__stdout = stdout
StringIO.StringIO.__init__(self)
StringIO.__init__(self)
def write(self,s):
self.__stdout.write(s)
StringIO.StringIO.write(self,s)
StringIO.write(self,s)
def read(self):
self.seek(0)
stuff = StringIO.StringIO.read(self)
stuff = StringIO.read(self)
self.__stdout.write(stuff)
return stuff
@@ -47,7 +48,7 @@ def setUp(self):
self.c = tw2.core.command.archive_tw2_resources(d)
try:
shutil.rmtree(OUT_DIR)
except Exception, e:
except Exception as e:
pass
os.mkdir(OUT_DIR)
@@ -81,7 +82,7 @@ def test_finalize_options_fail(self):
try:
self.c.finalize_options()
assert(False)
except ValueError, e:
except ValueError as e:
assert(
str(e) == "invalid literal for int() with base 10: 'not-an-int'"
)
@@ -136,7 +137,7 @@ def setUp(self):
try:
shutil.rmtree(OUT_DIR)
except Exception, e:
except Exception as e:
pass
self.c.initialize_options()
@@ -151,7 +152,7 @@ def setUp(self):
core.request_local()['middleware'] = middleware.make_middleware()
try:
core.request_local()['resources'] = []
except Exception, e:
except Exception as e:
pass
def tearDown(self):
@@ -160,12 +161,12 @@ def tearDown(self):
try:
shutil.rmtree(OUT_DIR)
except Exception, e:
except Exception as e:
pass
try:
shutil.rmtree(TMP_DIR)
except Exception, e:
except Exception as e:
pass
def test_load_widgets(self):
@@ -214,7 +215,7 @@ def test_render_entry_points(self):
rl_resources = core.request_local().setdefault('resources', [])
import pprint
print pprint.pformat(rl_resources)
pprint.pprint(rl_resources)
def test_copy_tree(self):
if HAS_SKIP:
@@ -19,7 +19,7 @@ def test_invalid_id(self):
try:
a = twc.Widget(id=':')
assert(False)
except twc.ParameterError, e:
except twc.ParameterError as e:
eq_(str(e), "Not a valid W3C id: ':'")
def test_id_none(self):
@@ -46,21 +46,21 @@ def test_widgetbunch(self):
try:
test.c
assert(False)
except AttributeError, e:
except AttributeError as e:
assert(str(e) == "Widget has no child named 'c'")
def xxtest_wb_nonwidget(self):
try:
test = twc.widgets.WidgetBunch(['hello'])
assert(False)
except twc.WidgetError, e:
except twc.WidgetError as e:
assert(str(e) == 'WidgetBunch may only contain Widgets')
def xxtest_wb_dupe(self):
try:
test = twc.widgets.WidgetBunch([twc.Widget(id='a'), twc.Widget(id='a')])
assert(False)
except twc.WidgetError, e:
except twc.WidgetError as e:
assert(str(e) == "WidgetBunch contains a duplicate id 'a'")
def test_cw_propagate(self):
@@ -107,24 +107,24 @@ def test_rw_propagate(self):
def test_rw_length(self):
testb = twc.RepeatingWidget(child=twc.Widget)
test = testb.req(value=range(10))
test = testb.req(value=list(range(10)))
test.repetitions = None
test.prepare()
assert(test.repetitions == 10)
test = testb.req(value=range(10))
test = testb.req(value=list(range(10)))
test.extra_reps = 5
test.repetitions = None
test.prepare()
assert(test.repetitions == 15)
test = testb.req(value=range(10))
test = testb.req(value=list(range(10)))
test.max_reps = 10
test.repetitions = None
test.prepare()
assert(test.repetitions == 10)
test = testb.req(value=range(10))
test = testb.req(value=list(range(10)))
test.max_reps = 30
test.min_reps = 20
test.repetitions = None
@@ -1,32 +1,33 @@
from unittest import TestCase
from tw2.core.mako_util import attrs
import six
fake_context = None
class TestMakoUtil(TestCase):
def test_normal_attrs(self):
s = attrs(fake_context, attrs={'a':5, 'b':3})
self.failUnless(s == u'a="5" b="3"' or s == u'b="3" a="5"')
self.failUnless(s == six.u('a="5" b="3"') or s == six.u('b="3" a="5"'))
def test_normal_attrs_as_args(self):
s = attrs(fake_context, {'a':5, 'b':3})
self.failUnless(s == u'a="5" b="3"' or s == u'b="3" a="5"')
self.failUnless(s == six.u('a="5" b="3"') or s == six.u('b="3" a="5"'))
def test_boolean_attrs(self):
s = attrs(fake_context, attrs={'a':True, 'b':False})
self.failUnless(s == u'a="True" b="False"' or s == u'b="False" a="True"')
self.failUnless(s == six.u('a="True" b="False"') or s == six.u('b="False" a="True"'))
def test_none_attrs(self):
"""Attributes with None values are not rendered"""
s = attrs(fake_context, attrs={'a':'hello', 'b':None})
self.assertEqual(s, u'a="hello"')
self.assertEqual(s, six.u('a="hello"'))
def test_special_boolean_html_attrs(self):
s = attrs(fake_context, attrs={'checked':True})
self.assertEqual(s, u'checked="checked"')
self.assertEqual(s, six.u('checked="checked"'))
s = attrs(fake_context, attrs={'checked':False})
self.assertEqual(s, u'')
self.assertEqual(s, six.u(''))
s = attrs(fake_context, attrs={'checked':None})
self.assertEqual(s, u'')
self.assertEqual(s, six.u(''))
@@ -4,6 +4,7 @@
from unittest import TestCase
from webob import Request, Response
import testapi
import six
class TestMiddlewareConfig(TestCase):
@@ -55,7 +56,7 @@ def testInjectResourcesUnicode(self):
the unicode body if the result of the resource injection is
unicode, so trying to figure out how to fake that
"""
fake_app = Response(unicode_body=u"\xea",
fake_app = Response(unicode_body=six.u("\xea"),
charset="utf8",
content_type="text/html")
@@ -1,4 +1,9 @@
import tw2.core as twc, testapi, thread
import tw2.core as twc, testapi
try:
import thread
except ImportError:
import _thread as thread
class TestMisc(object):
@@ -1,7 +1,8 @@
from nose.tools import eq_
import tw2.core as twc, testapi
import six
class Test(object):
__metaclass__ = twc.params.ParamMeta
class Test(six.with_metaclass(twc.params.ParamMeta, object)):
test1 = twc.Param('test_1', default=10)
class Test2(Test):
@@ -25,8 +26,7 @@ def setUp(self):
def test_parameter(self):
"Check a simple parameter"
class Test(object):
__metaclass__ = twc.params.ParamMeta
class Test(six.with_metaclass(twc.params.ParamMeta, object)):
test1 = twc.Param('test_1', default=10)
assert(len(Test._params) == 1)
@@ -60,10 +60,12 @@ class Test8(Test):
def test_override_default(self):
"Check overriding a parameter default"
class Test5(Test):
test1 = 11
assert(Test.test1 == 10)
assert(Test5.test1 == 11)
eq_(Test.test1, 10)
eq_(Test5.test1, 11)
def test_child(self):
assert(not hasattr(TestContainer, 'test'))
Oops, something went wrong.

0 comments on commit 4aef579

Please sign in to comment.