Fix compat layer patch and remove tests relative to it.

This commit is contained in:
Simon Chopin 2013-05-06 09:54:50 +00:00
parent c31070c622
commit d2c46d0087
2 changed files with 151 additions and 8 deletions

4
debian/changelog vendored
View File

@ -1,4 +1,4 @@
kitchen (1.1.1-1) UNRELEASED; urgency=low
kitchen (1.1.1-1) unstable; urgency=low
[ Simon Chopin ]
* Initial release. (Closes: #705930)
@ -7,4 +7,4 @@ kitchen (1.1.1-1) UNRELEASED; urgency=low
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.
-- Jakub Wilk <jwilk@debian.org> Sun, 05 May 2013 16:01:06 +0200
-- Simon Chopin <chopin.simon@gmail.com> Mon, 06 May 2013 11:45:55 +0200

View File

@ -17,23 +17,166 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
)
--- a/kitchen/text/converters.py
+++ b/kitchen/text/converters.py
@@ -53,7 +53,7 @@
@@ -53,8 +53,6 @@
# We need to access b_() for localizing our strings but we'll end up with
# a circular import if we import it directly.
import kitchen as k
-from kitchen.pycompat24 import sets
+import sets
sets.add_builtin_set()
-sets.add_builtin_set()
from kitchen.text.exceptions import ControlCharError, XmlEncodeError
from kitchen.text.misc import guess_encoding, html_entities_unescape, \
--- a/kitchen/text/misc.py
+++ b/kitchen/text/misc.py
@@ -40,7 +40,7 @@
@@ -40,11 +40,8 @@
# We need to access b_() for localizing our strings but we'll end up with
# a circular import if we import it directly.
import kitchen as k
-from kitchen.pycompat24 import sets
+import sets
from kitchen.text.exceptions import ControlCharError
sets.add_builtin_set()
-sets.add_builtin_set()
-
# Define a threshold for chardet confidence. If we fall below this we decode
# byte strings we're guessing about as latin1
_CHARDET_THRESHHOLD = 0.6
--- a/tests/test_pycompat.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-import unittest
-from nose import tools
-
-class TestUsableModules(unittest.TestCase):
- def test_subprocess(self):
- '''Test that importing subprocess as a module works
- '''
- try:
- from kitchen.pycompat24.subprocess import Popen
- except ImportError:
- tools.ok_(False, 'Unable to import pycompat24.subprocess as a module')
- try:
- from kitchen.pycompat27.subprocess import Popen
- except ImportError:
- tools.ok_(False, 'Unable to import pycompat27.subprocess as a module')
-
- def test_base64(self):
- '''Test that importing base64 as a module works
- '''
- try:
- from kitchen.pycompat24.base64 import b64encode
- except ImportError:
- tools.ok_(False, 'Unable to import pycompat24.base64 as a module')
--- a/tests/test_pycompat24.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-import unittest
-from nose import tools
-from nose.plugins.skip import SkipTest
-
-import __builtin__
-import base64 as py_b64
-import warnings
-
-from kitchen.pycompat24 import sets
-from kitchen.pycompat24.base64 import _base64 as base64
-
-class TestSetsNoOverwrite(unittest.TestCase):
- def setUp(self):
- self.set_val = None
- self.frozenset_val = None
- if not hasattr(__builtin__, 'set'):
- __builtin__.set = self.set_val
- else:
- self.set_val = __builtin__.set
- if not hasattr(__builtin__, 'frozenset'):
- __builtin__.frozenset = self.frozenset_val
- else:
- self.frozenset_val = __builtin__.frozenset
-
- def tearDown(self):
- if self.frozenset_val == None:
- del(__builtin__.frozenset)
- if self.set_val == None:
- del(__builtin__.set)
-
- def test_sets_dont_overwrite(self):
- '''Test that importing sets when there's already a set and frozenset defined does not overwrite
- '''
- sets.add_builtin_set()
- tools.ok_(__builtin__.set == self.set_val)
- tools.ok_(__builtin__.frozenset == self.frozenset_val)
-
-class TestDefineSets(unittest.TestCase):
- def setUp(self):
- warnings.simplefilter('ignore', DeprecationWarning)
- self.set_val = None
- self.frozenset_val = None
- if hasattr(__builtin__, 'set'):
- self.set_val = __builtin__.set
- del(__builtin__.set)
- if hasattr(__builtin__, 'frozenset'):
- self.frozenset_val = __builtin__.frozenset
- del(__builtin__.frozenset)
-
- def tearDown(self):
- warnings.simplefilter('default', DeprecationWarning)
- if self.set_val:
- __builtin__.set = self.set_val
- else:
- del(__builtin__.set)
- if self.frozenset_val:
- __builtin__.frozenset = self.frozenset_val
- else:
- del(__builtin__.frozenset)
-
- def test_pycompat_defines_set(self):
- '''Test that calling pycompat24.add_builtin_set() adds set and frozenset to __builtin__
- '''
- import sets as py_sets
- sets.add_builtin_set()
- if self.set_val:
- tools.ok_(__builtin__.set == self.set_val)
- tools.ok_(__builtin__.frozenset == self.frozenset_val)
- else:
- tools.ok_(__builtin__.set == py_sets.Set)
- tools.ok_(__builtin__.frozenset == py_sets.ImmutableSet)
-
-class TestSubprocess(unittest.TestCase):
- pass
-
-class TestBase64(unittest.TestCase):
- b_byte_chars = ' '.join(map(chr, range(0, 256)))
- b_byte_encoded = 'ACABIAIgAyAEIAUgBiAHIAggCSAKIAsgDCANIA4gDyAQIBEgEiATIBQgFSAWIBcgGCAZIBogGyAcIB0gHiAfICAgISAiICMgJCAlICYgJyAoICkgKiArICwgLSAuIC8gMCAxIDIgMyA0IDUgNiA3IDggOSA6IDsgPCA9ID4gPyBAIEEgQiBDIEQgRSBGIEcgSCBJIEogSyBMIE0gTiBPIFAgUSBSIFMgVCBVIFYgVyBYIFkgWiBbIFwgXSBeIF8gYCBhIGIgYyBkIGUgZiBnIGggaSBqIGsgbCBtIG4gbyBwIHEgciBzIHQgdSB2IHcgeCB5IHogeyB8IH0gfiB/IIAggSCCIIMghCCFIIYghyCIIIkgiiCLIIwgjSCOII8gkCCRIJIgkyCUIJUgliCXIJggmSCaIJsgnCCdIJ4gnyCgIKEgoiCjIKQgpSCmIKcgqCCpIKogqyCsIK0griCvILAgsSCyILMgtCC1ILYgtyC4ILkguiC7ILwgvSC+IL8gwCDBIMIgwyDEIMUgxiDHIMggySDKIMsgzCDNIM4gzyDQINEg0iDTINQg1SDWINcg2CDZINog2yDcIN0g3iDfIOAg4SDiIOMg5CDlIOYg5yDoIOkg6iDrIOwg7SDuIO8g8CDxIPIg8yD0IPUg9iD3IPgg+SD6IPsg/CD9IP4g/w=='
- b_byte_encoded_urlsafe = 'ACABIAIgAyAEIAUgBiAHIAggCSAKIAsgDCANIA4gDyAQIBEgEiATIBQgFSAWIBcgGCAZIBogGyAcIB0gHiAfICAgISAiICMgJCAlICYgJyAoICkgKiArICwgLSAuIC8gMCAxIDIgMyA0IDUgNiA3IDggOSA6IDsgPCA9ID4gPyBAIEEgQiBDIEQgRSBGIEcgSCBJIEogSyBMIE0gTiBPIFAgUSBSIFMgVCBVIFYgVyBYIFkgWiBbIFwgXSBeIF8gYCBhIGIgYyBkIGUgZiBnIGggaSBqIGsgbCBtIG4gbyBwIHEgciBzIHQgdSB2IHcgeCB5IHogeyB8IH0gfiB_IIAggSCCIIMghCCFIIYghyCIIIkgiiCLIIwgjSCOII8gkCCRIJIgkyCUIJUgliCXIJggmSCaIJsgnCCdIJ4gnyCgIKEgoiCjIKQgpSCmIKcgqCCpIKogqyCsIK0griCvILAgsSCyILMgtCC1ILYgtyC4ILkguiC7ILwgvSC-IL8gwCDBIMIgwyDEIMUgxiDHIMggySDKIMsgzCDNIM4gzyDQINEg0iDTINQg1SDWINcg2CDZINog2yDcIN0g3iDfIOAg4SDiIOMg5CDlIOYg5yDoIOkg6iDrIOwg7SDuIO8g8CDxIPIg8yD0IPUg9iD3IPgg-SD6IPsg_CD9IP4g_w=='
-
- def test_base64_encode(self):
- tools.ok_(base64.b64encode(self.b_byte_chars) == self.b_byte_encoded)
- tools.ok_(base64.b64encode(self.b_byte_chars, altchars='-_') == self.b_byte_encoded_urlsafe)
- tools.ok_(base64.standard_b64encode(self.b_byte_chars) == self.b_byte_encoded)
- tools.ok_(base64.urlsafe_b64encode(self.b_byte_chars) == self.b_byte_encoded_urlsafe)
-
- tools.ok_(base64.b64encode(self.b_byte_chars) == self.b_byte_encoded)
- tools.ok_(base64.b64encode(self.b_byte_chars, altchars='-_') == self.b_byte_encoded_urlsafe)
- tools.ok_(base64.standard_b64encode(self.b_byte_chars) == self.b_byte_encoded)
- tools.ok_(base64.urlsafe_b64encode(self.b_byte_chars) == self.b_byte_encoded_urlsafe)
-
- def test_base64_decode(self):
- tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
- tools.ok_(base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') == self.b_byte_chars)
- tools.ok_(base64.standard_b64decode(self.b_byte_encoded) == self.b_byte_chars)
- tools.ok_(base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) == self.b_byte_chars)
-
- tools.ok_(base64.b64decode(self.b_byte_encoded) == self.b_byte_chars)
- tools.ok_(base64.b64decode(self.b_byte_encoded_urlsafe, altchars='-_') == self.b_byte_chars)
- tools.ok_(base64.standard_b64decode(self.b_byte_encoded) == self.b_byte_chars)
- tools.ok_(base64.urlsafe_b64decode(self.b_byte_encoded_urlsafe) == self.b_byte_chars)
-
- def test_base64_stdlib_compat(self):
- if not hasattr(py_b64, 'b64encode'):
- raise SkipTest('Python-2.3 doesn\'t have b64encode to compare against')
- tools.ok_(base64.b64encode(self.b_byte_chars) == py_b64.b64encode(self.b_byte_chars))
- tools.ok_(base64.b64decode(self.b_byte_chars) == py_b64.b64decode(self.b_byte_chars))