Enable some tests against py33
Change-Id: Ibaf141784cbe08230cdb8f9aba3e5f376e7e1b93
This commit is contained in:
parent
f26ce10a4f
commit
c7b502bcf4
@ -31,14 +31,17 @@ class TestUtils(test.BaseTestCase):
|
||||
expected = 1356093296.12
|
||||
utc_datetime = datetime.datetime.utcfromtimestamp(expected)
|
||||
actual = utils.dt_to_decimal(utc_datetime)
|
||||
self.assertEqual(expected, float(actual))
|
||||
self.assertAlmostEqual(expected, float(actual), places=5)
|
||||
|
||||
def test_decimal_to_datetime(self):
|
||||
expected = 1356093296.12
|
||||
dexpected = decimal.Decimal(str(expected)) # Python 2.6 wants str()
|
||||
expected_datetime = datetime.datetime.utcfromtimestamp(expected)
|
||||
actual_datetime = utils.decimal_to_dt(dexpected)
|
||||
self.assertEqual(expected_datetime, actual_datetime)
|
||||
# Python 3 have rounding issue on this, so use float
|
||||
self.assertAlmostEqual(utils.dt_to_decimal(expected_datetime),
|
||||
utils.dt_to_decimal(actual_datetime),
|
||||
places=5)
|
||||
|
||||
def test_recursive_keypairs(self):
|
||||
data = {'a': 'A', 'b': 'B',
|
||||
@ -68,14 +71,26 @@ class TestUtils(test.BaseTestCase):
|
||||
big = 1 << 64
|
||||
expected = [('a', 'A'),
|
||||
('b', 'B'),
|
||||
('nested:list', ['{%d: 99, %dL: 42}' % (small, big)])]
|
||||
# the keys 1 and 1<<64 cause a hash collision on 64bit platforms
|
||||
for nested in [{small: 99, big: 42}, {big: 42, small: 99}]:
|
||||
data = {'a': 'A',
|
||||
'b': 'B',
|
||||
'nested': {'list': [nested]}}
|
||||
pairs = list(utils.recursive_keypairs(data))
|
||||
self.assertEqual(expected, pairs)
|
||||
('nested:list', ['{%d: 99, %d: 42}' % (small, big)])]
|
||||
data = {'a': 'A',
|
||||
'b': 'B',
|
||||
'nested': {'list': [{small: 99, big: 42}]}}
|
||||
pairs = list(utils.recursive_keypairs(data))
|
||||
self.assertEqual(len(expected), len(pairs))
|
||||
for k, v in pairs:
|
||||
# the keys 1 and 1<<64 cause a hash collision on 64bit platforms
|
||||
if k == 'nested:list':
|
||||
self.assertIn(v,
|
||||
[[('{%d: 99, %d: 42}'
|
||||
% (small, big)).encode('ascii')],
|
||||
[('{%d: 99, %dL: 42}'
|
||||
% (small, big)).encode('ascii')],
|
||||
[('{%d: 42, %d: 99}'
|
||||
% (big, small)).encode('ascii')],
|
||||
[('{%dL: 42, %d: 99}'
|
||||
% (big, small)).encode('ascii')]])
|
||||
else:
|
||||
self.assertIn((k, v), expected)
|
||||
|
||||
def test_restore_nesting_unested(self):
|
||||
metadata = {'a': 'A', 'b': 'B'}
|
||||
@ -124,9 +139,9 @@ class TestUtils(test.BaseTestCase):
|
||||
'nested2': [{'c': 'A'}, {'c': 'B'}]
|
||||
}
|
||||
pairs = list(utils.dict_to_keyval(data))
|
||||
self.assertEqual([('a', 'A'), ('b', 'B'),
|
||||
('nested2[0].c', 'A'),
|
||||
('nested2[1].c', 'B'),
|
||||
('nested.a', 'A'),
|
||||
('nested.b', 'B')],
|
||||
pairs)
|
||||
self.assertEqual(set([('a', 'A'), ('b', 'B'),
|
||||
('nested2[0].c', 'A'),
|
||||
('nested2[1].c', 'B'),
|
||||
('nested.a', 'A'),
|
||||
('nested.b', 'B')]),
|
||||
set(pairs))
|
||||
|
@ -58,7 +58,7 @@ def recursive_keypairs(d, separator=':'):
|
||||
def restore_nesting(d, separator=':'):
|
||||
"""Unwinds a flattened dict to restore nesting."""
|
||||
d = copy.copy(d) if any([separator in k for k in d.keys()]) else d
|
||||
for k, v in d.items():
|
||||
for k, v in d.copy().items():
|
||||
if separator in k:
|
||||
top, rem = k.split(separator, 1)
|
||||
nest = d[top] if isinstance(d.get(top), dict) else {}
|
||||
|
34
requirements-py3.txt
Normal file
34
requirements-py3.txt
Normal file
@ -0,0 +1,34 @@
|
||||
alembic>=0.6.4
|
||||
anyjson>=0.3.3
|
||||
argparse
|
||||
croniter>=0.3.4 # MIT License
|
||||
eventlet>=0.13.0
|
||||
iso8601>=0.1.9
|
||||
jsonpath-rw>=1.2.0,<2.0
|
||||
jsonschema>=2.0.0,<3.0.0
|
||||
lockfile>=0.8
|
||||
lxml>=2.3
|
||||
msgpack-python>=0.4.0
|
||||
netaddr>=0.7.6
|
||||
oslo.config>=1.2.1
|
||||
PasteDeploy>=1.5.0
|
||||
pbr>=0.6,!=0.7,<1.0
|
||||
pecan>=0.5.0
|
||||
posix_ipc
|
||||
oslo.messaging>=1.3.0
|
||||
pysnmp>=4.2.1,<5.0.0
|
||||
python-ceilometerclient>=1.0.6
|
||||
python-glanceclient>=0.13.1
|
||||
python-keystoneclient>=0.9.0
|
||||
python-neutronclient>=2.3.5,<3
|
||||
python-novaclient>=2.17.0
|
||||
python-swiftclient>=2.0.2
|
||||
pytz>=2010h
|
||||
PyYAML>=3.1.0
|
||||
requests>=1.1
|
||||
six>=1.7.0
|
||||
SQLAlchemy>=0.8.4,!=0.9.5,<=0.9.99
|
||||
sqlalchemy-migrate>=0.9.1
|
||||
stevedore>=0.14
|
||||
WebOb>=1.2.3
|
||||
WSME>=0.6
|
22
test-requirements-py3.txt
Normal file
22
test-requirements-py3.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking>=0.9.2,<0.10
|
||||
Babel>=1.3
|
||||
coverage>=3.6
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
httplib2>=0.7.5
|
||||
http://tarballs.openstack.org/swift/swift-master.tar.gz#egg=swift
|
||||
mock>=1.0
|
||||
mox>=0.5.3
|
||||
# Docs Requirements
|
||||
oslosphinx
|
||||
oslotest
|
||||
pymongo>=2.5
|
||||
python-subunit>=0.0.18
|
||||
sphinx>=1.1.2,!=1.2.0,<1.3
|
||||
sphinxcontrib-docbookrestapi
|
||||
sphinxcontrib-httpdomain
|
||||
sphinxcontrib-pecanwsme>=0.8
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=0.9.34
|
6
tox.ini
6
tox.ini
@ -18,6 +18,12 @@ commands =
|
||||
downloadcache = {toxworkdir}/_download
|
||||
whitelist_externals = bash
|
||||
|
||||
[testenv:py33]
|
||||
deps = -r{toxinidir}/requirements-py3.txt
|
||||
-r{toxinidir}/test-requirements-py3.txt
|
||||
commands = python -m testtools.run \
|
||||
ceilometer.tests.test_utils
|
||||
|
||||
[testenv:cover]
|
||||
commands = bash -x {toxinidir}/setup-test-env.sh python setup.py testr --slowest --coverage --testr-args="{posargs}"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user