Commit 749d4970 authored by Stephan Richter's avatar Stephan Richter

Fix a few more tests.

parent e64a066d
include *.txt
include MANIFEST.in
include buildout.cfg
include compat.cfg
recursive-include src *.py *.txt *.zcml *.c
recursive-include include *.h *.txt
......@@ -310,18 +310,18 @@ class ItemTypePrecondition(_TypesBased):
>>> try:
... precondition(None, 'foo', ob)
... except InvalidItemType as v:
... print(v.args[0], (v.args[1] is ob), (v.args[2] == (I1, I2)))
... v.args[0], (v.args[1] is ob), (v.args[2] == (I1, I2))
... else:
... print('Should have failed')
None True True
(None, True, True)
>>> try:
... precondition.factory(None, 'foo', factory)
... except InvalidItemType as v:
... print(v.args[0], (v.args[1] is factory), (v.args[2] == (I1, I2)))
... v.args[0], (v.args[1] is factory), (v.args[2] == (I1, I2))
... else:
... print('Should have failed')
None True True
(None, True, True)
>>> zope.interface.classImplements(Ob, I2)
>>> precondition(None, 'foo', ob)
......@@ -416,15 +416,14 @@ class ContainerTypesConstraint(_TypesBased):
>>> try:
... constraint(ob)
... except InvalidContainerType as v:
... print((v.args[0] is ob), (v.args[1] == (I1, I2)))
... (v.args[0] is ob), (v.args[1] == (I1, I2))
... else:
... print('Should have failed')
True True
(True, True)
>>> zope.interface.classImplements(Ob, I2)
>>> constraint(Ob())
True
"""
def __call__(self, object):
for iface in self.types:
......
......@@ -13,6 +13,7 @@
##############################################################################
"""Classes to support implementing `IContained`
"""
import sys
import zope.component
import zope.interface.declarations
from zope.interface import providedBy, Interface
......@@ -47,6 +48,8 @@ except NameError:
# Py3: Define unicode type.
unicode = str
PY3 = sys.version_info[0] >= 3
@zope.interface.implementer(IContained)
class Contained(object):
"""Stupid mix-in that defines `__parent__` and `__name__` attributes"""
......@@ -521,7 +524,8 @@ def setitem(container, setitemf, name, object):
...
TypeError: name not unicode or ascii string
>>> setitem(container, container.__setitem__, b'hello ' + bytes([200]), item)
>>> c = bytes([200]) if PY3 else chr(200)
>>> setitem(container, container.__setitem__, b'hello ' + c, item)
Traceback (most recent call last):
...
TypeError: name not unicode or ascii string
......
......@@ -13,12 +13,14 @@
##############################################################################
"""Container constraint tests
"""
from __future__ import print_function
import doctest
import unittest
from zope.testing import module
from zope.container import testing
def setUp(test):
test.globs['print_function'] = print_function
module.setUp(test, 'zope.container.constraints_txt')
def tearDown(test):
......
......@@ -4,3 +4,53 @@ envlist = py26,py27,py33
[testenv]
commands = python setup.py test -q
deps = zope.testrunner
zope.testing
six
zope.interface
zope.dottedname
zope.schema
zope.component
zope.event
zope.location
zope.security
zope.lifecycleevent
zope.i18nmessageid
zope.filerepresentation
zope.size
zope.traversing
zope.publisher
persistent
BTrees
[testenv:coverage]
basepython =
python2.7
commands =
# The installed version messes up nose's test discovery / coverage reporting
# So, we uninstall that from the environment, and then install the editable
# version, before running nosetests.
pip uninstall -y zope.container
pip install -e .
nosetests --with-xunit --with-xcoverage
deps =
nose
coverage
nosexcover
zope.testrunner
zope.testing
six
zope.interface
zope.dottedname
zope.schema
zope.component
zope.event
zope.location
zope.security
zope.lifecycleevent
zope.i18nmessageid
zope.filerepresentation
zope.size
zope.traversing
zope.publisher
persistent
BTrees
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment