Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
69b5b252
Commit
69b5b252
authored
Jun 28, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert doctests to unittests.
parent
13ad544d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
58 deletions
+22
-58
persistent/tests/test_persistent.py
persistent/tests/test_persistent.py
+0
-57
persistent/tests/test_pyPersistence.py
persistent/tests/test_pyPersistence.py
+22
-1
No files found.
persistent/tests/test_persistent.py
deleted
100644 → 0
View file @
13ad544d
##############################################################################
#
# Copyright (c) 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.
#
##############################################################################
import
unittest
try
:
from
persistent
import
simple_new
except
ImportError
:
simple_new
=
None
def
cpersistent_setstate_pointer_sanity
():
"""
>>> from persistent import Persistent
>>> class P(Persistent):
... def __init__(self):
... self.x = 0
... def inc(self):
... self.x += 1
>>>
>>> Persistent().__setstate__({})
Traceback (most recent call last):
...
TypeError: this object has no instance dictionary
>>> class C(Persistent): __slots__ = 'x', 'y'
>>> C().__setstate__(({}, {}))
Traceback (most recent call last):
...
TypeError: this object has no instance dictionary
"""
if
simple_new
is
not
None
:
def
cpersistent_simple_new_invalid_argument
():
"""
>>> simple_new('')
Traceback (most recent call last):
...
TypeError: simple_new argument must be a type object.
"""
def
test_suite
():
import
doctest
return
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
"persistent.txt"
),
doctest
.
DocTestSuite
(),
))
persistent/tests/test_pyPersistence.py
View file @
69b5b252
...
...
@@ -1118,7 +1118,8 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
def
_clearMRU
(
self
,
jar
):
jar
.
_cache
.
_mru
[:]
=
[]
_add_to_suite
=
[
PyPersistentTests
]
try
:
from
persistent
import
cPersistence
...
...
@@ -1140,3 +1141,23 @@ else:
def
_makeCache
(
self
,
jar
):
from
persistent.cPickleCache
import
PickleCache
return
PickleCache
(
jar
)
_add_to_suite
.
append
(
CPersistentTests
)
class
Test_simple_new
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
x
):
from
persistent.cPersistence
import
simple_new
return
simple_new
(
x
)
def
test_w_non_type
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
_callFUT
,
''
)
def
test_w_type
(
self
):
for
typ
in
(
type
,
list
,
dict
,
tuple
,
object
):
self
.
assertTrue
(
isinstance
(
self
.
_callFUT
(
typ
),
typ
))
_add_to_suite
.
append
(
Test_simple_new
)
def
test_suite
():
return
unittest
.
TestSuite
(
_add_to_suite
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment