-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flake8, move tests into a tests module.
- Loading branch information
Showing
8 changed files
with
68 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ ignore = | |
[flake8] | ||
ignore = N801,N802,N803,N805,N806,N812,E301 | ||
exclude = bootstrap.py | ||
max-complexity = 70 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2002 Zope Foundation and Contributors. | ||
# | ||
# 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 | ||
# | ||
############################################################################## | ||
|
||
from cStringIO import StringIO | ||
import pickle | ||
import unittest | ||
|
||
from TreeDisplay.TreeTag import ( | ||
MiniUnpickler, | ||
) | ||
|
||
|
||
class _junk_class(object): | ||
pass | ||
|
||
|
||
class TestMiniPickle(unittest.TestCase): | ||
|
||
def _should_succeed(self, x, binary=1): | ||
if x != MiniUnpickler(StringIO(pickle.dumps(x, binary))).load(): | ||
raise ValueError(x) | ||
|
||
def _should_fail(self, x, binary=1): | ||
try: | ||
MiniUnpickler(StringIO(pickle.dumps(x, binary))).load() | ||
raise ValueError(x) | ||
except pickle.UnpicklingError as e: | ||
if e[0] != 'Refused': | ||
raise ValueError(x) | ||
|
||
def test_mini_pickle(self): | ||
self._should_succeed('hello') | ||
self._should_succeed(1) | ||
self._should_succeed(1.0) | ||
self._should_succeed((1, 2, 3)) | ||
self._should_succeed([1, 2, 3]) | ||
self._should_succeed({1: 2, 3: 4}) | ||
self._should_fail(open) | ||
self._should_fail(_junk_class) | ||
self._should_fail(_junk_class()) |