Remove oslo namespace package
Blueprint remove-namespace-packages Depends-on: I950f1afb1b4600dfc1f38d1a7d9322f240f444a6 for openstack/cinder Depends-on: I1fd9eba88ec8d436f6d2e37df851dbaa84a8c78c for openstack/glance_store Change-Id: I44badf246dde417c6f54bab74716ddbaaee333f1
This commit is contained in:
parent
7e0d0a1cdf
commit
4e2ca43093
@ -1,13 +0,0 @@
|
|||||||
# 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. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
__import__('pkg_resources').declare_namespace(__name__)
|
|
@ -1,26 +0,0 @@
|
|||||||
# 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. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
|
|
||||||
def deprecated():
|
|
||||||
new_name = __name__.replace('.', '_')
|
|
||||||
warnings.warn(
|
|
||||||
('The oslo namespace package is deprecated. Please use %s instead.' %
|
|
||||||
new_name),
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=3,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
deprecated()
|
|
@ -1,13 +0,0 @@
|
|||||||
# 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. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from oslo_serialization.jsonutils import * # noqa
|
|
@ -21,11 +21,7 @@ classifier =
|
|||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
oslo
|
|
||||||
oslo.serialization
|
|
||||||
oslo_serialization
|
oslo_serialization
|
||||||
namespace_packages =
|
|
||||||
oslo
|
|
||||||
|
|
||||||
[pbr]
|
[pbr]
|
||||||
warnerrors = true
|
warnerrors = true
|
||||||
|
@ -1,154 +0,0 @@
|
|||||||
# Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# 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. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import itertools
|
|
||||||
import sys
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
import netaddr
|
|
||||||
from oslotest import base as test_base
|
|
||||||
from pytz import timezone
|
|
||||||
import six
|
|
||||||
import six.moves.xmlrpc_client as xmlrpclib
|
|
||||||
import testtools
|
|
||||||
|
|
||||||
from oslo_serialization import msgpackutils
|
|
||||||
|
|
||||||
# NOTE(harlowja): itertools.count only started to take a step value
|
|
||||||
# in python 2.7+ so we can't use it in 2.6...
|
|
||||||
if sys.version_info[0:2] == (2, 6):
|
|
||||||
_PY26 = True
|
|
||||||
else:
|
|
||||||
_PY26 = False
|
|
||||||
|
|
||||||
|
|
||||||
_TZ_FMT = '%Y-%m-%d %H:%M:%S %Z%z'
|
|
||||||
|
|
||||||
|
|
||||||
def _dumps_loads(obj):
|
|
||||||
obj = msgpackutils.dumps(obj)
|
|
||||||
return msgpackutils.loads(obj)
|
|
||||||
|
|
||||||
|
|
||||||
class MsgPackUtilsTestMixin(test_base.BaseTestCase):
|
|
||||||
def test_list(self):
|
|
||||||
self.assertEqual(_dumps_loads([1, 2, 3]), [1, 2, 3])
|
|
||||||
|
|
||||||
def test_empty_list(self):
|
|
||||||
self.assertEqual(_dumps_loads([]), [])
|
|
||||||
|
|
||||||
def test_tuple(self):
|
|
||||||
# Seems like we do lose whether it was a tuple or not...
|
|
||||||
#
|
|
||||||
# Maybe fixed someday:
|
|
||||||
#
|
|
||||||
# https://github.com/msgpack/msgpack-python/issues/98
|
|
||||||
self.assertEqual(_dumps_loads((1, 2, 3)), [1, 2, 3])
|
|
||||||
|
|
||||||
def test_dict(self):
|
|
||||||
self.assertEqual(_dumps_loads(dict(a=1, b=2, c=3)),
|
|
||||||
dict(a=1, b=2, c=3))
|
|
||||||
|
|
||||||
def test_empty_dict(self):
|
|
||||||
self.assertEqual(_dumps_loads({}), {})
|
|
||||||
|
|
||||||
def test_complex_dict(self):
|
|
||||||
src = {
|
|
||||||
'now': datetime.datetime(1920, 2, 3, 4, 5, 6, 7),
|
|
||||||
'later': datetime.datetime(1921, 2, 3, 4, 5, 6, 9),
|
|
||||||
'a': 1,
|
|
||||||
'b': 2.0,
|
|
||||||
'c': [],
|
|
||||||
'd': set([1, 2, 3]),
|
|
||||||
'zzz': uuid.uuid4(),
|
|
||||||
'yyy': 'yyy',
|
|
||||||
'ddd': b'bbb',
|
|
||||||
'today': datetime.date.today(),
|
|
||||||
}
|
|
||||||
self.assertEqual(_dumps_loads(src), src)
|
|
||||||
|
|
||||||
def test_itercount(self):
|
|
||||||
it = itertools.count(1)
|
|
||||||
six.next(it)
|
|
||||||
six.next(it)
|
|
||||||
it2 = _dumps_loads(it)
|
|
||||||
self.assertEqual(six.next(it), six.next(it2))
|
|
||||||
|
|
||||||
it = itertools.count(0)
|
|
||||||
it2 = _dumps_loads(it)
|
|
||||||
self.assertEqual(six.next(it), six.next(it2))
|
|
||||||
|
|
||||||
@testtools.skipIf(_PY26, 'itertools.count step not supported')
|
|
||||||
def test_itercount_step(self):
|
|
||||||
it = itertools.count(1, 3)
|
|
||||||
it2 = _dumps_loads(it)
|
|
||||||
self.assertEqual(six.next(it), six.next(it2))
|
|
||||||
|
|
||||||
def test_set(self):
|
|
||||||
self.assertEqual(_dumps_loads(set([1, 2])), set([1, 2]))
|
|
||||||
|
|
||||||
def test_empty_set(self):
|
|
||||||
self.assertEqual(_dumps_loads(set([])), set([]))
|
|
||||||
|
|
||||||
def test_frozenset(self):
|
|
||||||
self.assertEqual(_dumps_loads(frozenset([1, 2])), frozenset([1, 2]))
|
|
||||||
|
|
||||||
def test_empty_frozenset(self):
|
|
||||||
self.assertEqual(_dumps_loads(frozenset([])), frozenset([]))
|
|
||||||
|
|
||||||
def test_datetime_preserve(self):
|
|
||||||
x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7)
|
|
||||||
self.assertEqual(_dumps_loads(x), x)
|
|
||||||
|
|
||||||
def test_datetime(self):
|
|
||||||
x = xmlrpclib.DateTime()
|
|
||||||
x.decode("19710203T04:05:06")
|
|
||||||
self.assertEqual(_dumps_loads(x), x)
|
|
||||||
|
|
||||||
def test_ipaddr(self):
|
|
||||||
thing = {'ip_addr': netaddr.IPAddress('1.2.3.4')}
|
|
||||||
self.assertEqual(_dumps_loads(thing), thing)
|
|
||||||
|
|
||||||
def test_today(self):
|
|
||||||
today = datetime.date.today()
|
|
||||||
self.assertEqual(today, _dumps_loads(today))
|
|
||||||
|
|
||||||
def test_datetime_tz_clone(self):
|
|
||||||
eastern = timezone('US/Eastern')
|
|
||||||
now = datetime.datetime.now()
|
|
||||||
e_dt = eastern.localize(now)
|
|
||||||
e_dt2 = _dumps_loads(e_dt)
|
|
||||||
self.assertEqual(e_dt, e_dt2)
|
|
||||||
self.assertEqual(e_dt.strftime(_TZ_FMT), e_dt2.strftime(_TZ_FMT))
|
|
||||||
|
|
||||||
def test_datetime_tz_different(self):
|
|
||||||
eastern = timezone('US/Eastern')
|
|
||||||
pacific = timezone('US/Pacific')
|
|
||||||
now = datetime.datetime.now()
|
|
||||||
|
|
||||||
e_dt = eastern.localize(now)
|
|
||||||
p_dt = pacific.localize(now)
|
|
||||||
|
|
||||||
self.assertNotEqual(e_dt, p_dt)
|
|
||||||
self.assertNotEqual(e_dt.strftime(_TZ_FMT), p_dt.strftime(_TZ_FMT))
|
|
||||||
|
|
||||||
e_dt2 = _dumps_loads(e_dt)
|
|
||||||
p_dt2 = _dumps_loads(p_dt)
|
|
||||||
|
|
||||||
self.assertNotEqual(e_dt2, p_dt2)
|
|
||||||
self.assertNotEqual(e_dt2.strftime(_TZ_FMT), p_dt2.strftime(_TZ_FMT))
|
|
||||||
|
|
||||||
self.assertEqual(e_dt, e_dt2)
|
|
||||||
self.assertEqual(p_dt, p_dt2)
|
|
@ -1,61 +0,0 @@
|
|||||||
# 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. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import imp
|
|
||||||
import os
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
import mock
|
|
||||||
from oslotest import base as test_base
|
|
||||||
import six
|
|
||||||
|
|
||||||
|
|
||||||
class DeprecationWarningTest(test_base.BaseTestCase):
|
|
||||||
|
|
||||||
@mock.patch('warnings.warn')
|
|
||||||
def test_warning(self, mock_warn):
|
|
||||||
import oslo.serialization
|
|
||||||
imp.reload(oslo.serialization)
|
|
||||||
self.assertTrue(mock_warn.called)
|
|
||||||
args = mock_warn.call_args
|
|
||||||
self.assertIn('oslo_serialization', args[0][0])
|
|
||||||
self.assertIn('deprecated', args[0][0])
|
|
||||||
self.assertTrue(issubclass(args[0][1], DeprecationWarning))
|
|
||||||
|
|
||||||
def test_real_warning(self):
|
|
||||||
with warnings.catch_warnings(record=True) as warning_msgs:
|
|
||||||
warnings.resetwarnings()
|
|
||||||
warnings.simplefilter('always', DeprecationWarning)
|
|
||||||
import oslo.serialization
|
|
||||||
|
|
||||||
# Use a separate function to get the stack level correct
|
|
||||||
# so we know the message points back to this file. This
|
|
||||||
# corresponds to an import or reload, which isn't working
|
|
||||||
# inside the test under Python 3.3. That may be due to a
|
|
||||||
# difference in the import implementation not triggering
|
|
||||||
# warnings properly when the module is reloaded, or
|
|
||||||
# because the warnings module is mostly implemented in C
|
|
||||||
# and something isn't cleanly resetting the global state
|
|
||||||
# used to track whether a warning needs to be
|
|
||||||
# emitted. Whatever the cause, we definitely see the
|
|
||||||
# warnings.warn() being invoked on a reload (see the test
|
|
||||||
# above) and warnings are reported on the console when we
|
|
||||||
# run the tests. A simpler test script run outside of
|
|
||||||
# testr does correctly report the warnings.
|
|
||||||
def foo():
|
|
||||||
oslo.serialization.deprecated()
|
|
||||||
|
|
||||||
foo()
|
|
||||||
self.assertEqual(1, len(warning_msgs))
|
|
||||||
msg = warning_msgs[0]
|
|
||||||
self.assertIn('oslo_serialization', six.text_type(msg.message))
|
|
||||||
self.assertEqual('test_warning.py', os.path.basename(msg.filename))
|
|
Loading…
Reference in New Issue
Block a user