Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #6: Broken test_sortkeys() plus other updates. #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cbor/cbor_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def close(self):
self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close()
except socket.error:
logger.warn('error closing lockd client socket',
logger.warning('error closing lockd client socket',
exc_info=True)
self._socket = None

Expand Down Expand Up @@ -172,4 +172,4 @@ def _rpc(self, method_name, params):
#print(client._rpc(u'ping', []))
#print(client._rpc(u'gnip', []))
client.close()

8 changes: 6 additions & 2 deletions cbor/tests/test_cbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from cbor._cbor import load as cload
except ImportError:
# still test what we can without C fast mode
logger.warn('testing without C accelerated CBOR', exc_info=True)
logger.warning('testing without C accelerated CBOR', exc_info=True)
cdumps, cloads, cdump, cload = None, None, None, None


Expand Down Expand Up @@ -62,7 +62,7 @@ def dump(cls, *args, **kwargs):
def testable(cls):
ok = (cls._ld[0] is not None) and (cls._ld[1] is not None) and (cls._ld[3] is not None) and (cls._ld[4] is not None)
if not ok:
logger.warn('non-testable case %s skipped', cls.__name__)
logger.warning('non-testable case %s skipped', cls.__name__)
return ok

# Can't set class level function pointers, because then they expect a
Expand Down Expand Up @@ -281,6 +281,10 @@ def test_sortkeys(self):
xbytes = []
for n in _range(2, 27):
ob = {u'{:02x}'.format(x):x for x in _range(n)}
# ensure some "ob" have unsorted key:value entries
if n in [4, 6, 9]:
ob.pop('01')
ob["01"] = 1
obytes.append(self.dumps(ob, sort_keys=True))
xbytes.append(self.dumps(ob, sort_keys=False))
allOGood = True
Expand Down
10 changes: 5 additions & 5 deletions cbor/tests/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from cbor._cbor import load as cload
except ImportError:
# still test what we can without C fast mode
logger.warn('testing without C accelerated CBOR', exc_info=True)
logger.warning('testing without C accelerated CBOR', exc_info=True)
cdumps, cloads, cdump, cload = None, None, None, None


Expand All @@ -48,7 +48,7 @@ def test_dumps_usage(self):
repeatedly serialize, check that usage doesn't go up
'''
if cdumps is None:
logger.warn('no C dumps(), skipping test_dumps_usage')
logger.warning('no C dumps(), skipping test_dumps_usage')
return
start_usage = resource.getrusage(resource.RUSAGE_SELF)
usage_history = [start_usage]
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_loads_usage(self):
repeatedly serialize, check that usage doesn't go up
'''
if (cdumps is None) or (cloads is None):
logger.warn('no C fast CBOR, skipping test_loads_usage')
logger.warning('no C fast CBOR, skipping test_loads_usage')
return
## Just a string passes!
#ob = 'sntaoheusnatoheusnaotehuasnoetuhaosentuhaoesnth'
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_tempfile(self):
it, checking usage all along the way.
'''
if cdump is None:
logger.warn('no C dump(), skipping test_tempfile')
logger.warning('no C dump(), skipping test_tempfile')
return
with tempfile.NamedTemporaryFile() as ntf:
# first, write a bunch to temp file
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_tempfile(self):
def test_stringio_usage(self):
'''serialize data to StringIO, read it back'''
if cdump is None:
logger.warn('no C dump(), skipping test_tempfile')
logger.warning('no C dump(), skipping test_tempfile')
return

# warmup the rusage, allocate everything!
Expand Down
2 changes: 1 addition & 1 deletion cbor/tests/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from cbor._cbor import loads as cloads
except ImportError:
# still test what we can without C fast mode
logger.warn('testing without C accelerated CBOR', exc_info=True)
logger.warning('testing without C accelerated CBOR', exc_info=True)
#cdumps, cloads = None, None
cloads = None
from cbor import Tag
Expand Down
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#! /usr/bin/env python
# Copyright 2014 Brian Olson
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -75,7 +75,7 @@ def build_extension(self, ext):
author='Brian Olson',
author_email='[email protected]',
url='https://github.com/brianolson/cbor_py',
packages=['cbor'],
packages=['cbor', 'cbor/tests'],
package_dir={'cbor':'cbor'},
ext_modules=[
Extension(
Expand All @@ -94,6 +94,9 @@ def build_extension(self, ext):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: C',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down