Commit 146255e0 authored by Jason Madden's avatar Jason Madden

Test the docs on Python 2 and 3 using manuel. This gets a lot of coverage of...

Test the docs on Python 2 and 3 using manuel. This gets a lot of coverage of tests.attrhooks, tests.cucumbers and tests.utils.
parent 889b615c
......@@ -47,13 +47,13 @@ Caches have a :meth:`new_ghost` method that:
>>> jar = ResettingJar()
>>> cache = persistent.PickleCache(jar, 10, 100)
>>> ob = C.__new__(C)
>>> cache.new_ghost('1', ob)
>>> cache.new_ghost(b'1', ob)
>>> ob._p_changed
>>> ob._p_jar is jar
True
>>> ob._p_oid
'1'
>>> ob._p_oid == b'1'
True
>>> cache.cache_non_ghost_count
0
......@@ -18,8 +18,8 @@ machinery happy:
>>> f, (c,), state = x.__reduce__()
>>> f.__name__
'__newobj__'
>>> f.__module__
'copy_reg'
>>> f.__module__.replace('_', '') # Normalize Python2/3
'copyreg'
>>> c.__name__
'Simple'
......@@ -57,8 +57,8 @@ by overriding :meth:`__getnewargs__`, :meth:`__getstate__` and
>>> (f, (c, ax, ay), a) = x.__reduce__()
>>> f.__name__
'__newobj__'
>>> f.__module__
'copy_reg'
>>> f.__module__.replace('_', '') # Normalize Python2/3
'copyreg'
>>> c.__name__
'Custom'
>>> ax, ay, a
......@@ -79,7 +79,6 @@ ignores any slots which map onto the "persistent" namespace (prefixed with
.. doctest::
>>> import copy_reg
>>> from persistent.tests.cucumbers import SubSlotted
>>> x = SubSlotted('x', 'y', 'z')
......
......@@ -467,7 +467,7 @@ class Persistent(object):
""" See IPersistent.
"""
if name.startswith('_p_'):
setattr(self, name, value)
_OSA(self, name, value)
return True
self._p_activate()
self._p_accessed()
......
......@@ -18,8 +18,7 @@ from persistent._compat import PYTHON2
def print_dict(d):
d = d.items()
d.sort()
d = sorted(d.items())
print('{%s}' % (', '.join(
[('%r: %r' % (k, v)) for (k, v) in d]
)))
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Tests for the documentation.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# disable: accessing protected members, too many methods
# pylint: disable=W0212,R0904
import os.path
import unittest
import doctest
import manuel.capture
import manuel.codeblock
import manuel.doctest
import manuel.ignore
import manuel.testing
def test_suite():
here = os.path.dirname(__file__)
while not os.path.exists(os.path.join(here, 'setup.py')):
here = os.path.join(here, '..')
here = os.path.abspath(here)
docs = os.path.join(here, 'docs', 'api')
files_to_test = (
'cache.rst',
'attributes.rst',
'pickling.rst',
)
paths = [os.path.join(docs, f) for f in files_to_test]
m = manuel.ignore.Manuel()
m += manuel.doctest.Manuel(optionflags=(
doctest.NORMALIZE_WHITESPACE
| doctest.ELLIPSIS
| doctest.IGNORE_EXCEPTION_DETAIL
))
m += manuel.codeblock.Manuel()
m += manuel.capture.Manuel()
suite = unittest.TestSuite()
suite.addTest(
manuel.testing.TestSuite(
m,
*paths
)
)
return suite
......@@ -116,6 +116,7 @@ setup(name='persistent',
'test': [
'zope.testrunner',
"cffi ; platform_python_implementation == 'CPython'",
'manuel',
],
'testing': (),
'docs': [
......
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