6 Commits

Author SHA1 Message Date
Sean McGinnis
4669bcc628
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I12e1a2a4a22116cabd09a3b808f871d98e4bd1f2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-01 07:57:23 -05:00
zhanghao
3cfa54fa56 Remove usage of six
With python3.x, classes can use 'metaclass=' instead of
'six.add_metaclass', 'six.iteritems' and 'six.iterkeys' can
be replaced by 'items' and 'keys', 'six.moves.urllib.parse'
can be replaced by 'urllib.parse', 'six.StringIO' and
'six.moves.cStringIO' can be replaced by 'io.StringIO',
'six.text_type' and 'six.string_type' are just 'str'.

Change-Id: I357968c6a1932856b1600f6c191966bc90cbc258
2020-05-15 17:27:56 -04:00
Rodolfo Alonso Hernandez
a363edd761 Avoid py36 error when printing unicode chars in a stream
The IOStream was not able to encode characters out of range 128:
  "UnicodeEncodeError: 'ascii' codec can't encode characters in
   position 19-21: ordinal not in range(128)"

Change-Id: Ic95396a5cf73c49d332928857dc064819a6d7ea6
Closes-Bug: #1858421
2020-01-10 18:57:25 +00:00
Akihiro Motoki
c66f9726c0 Drop deprecated neutronclient.i18n wrapper
In favor of the private i18n wrapper (_i18n), the public 'i18n' wrapper
has been deprecated for several releases. Each neutron CLI plugin
(not OSC plugin) should use its own i18n wrapper and the usage of
neutronclient.i18n wrapper was deprecated. It is time to drop this.

Also fixes test_exception.py which still consumed neutronclient.i18n.

Change-Id: I27a8ace2f31bea5e1d6bf8a5ebbbfa52a3228e73
2017-05-14 20:10:47 +00:00
Akihiro Motoki
266e6c3c3c Decode exception parameters to expand exception message properly
If a multibyte string without unicode prefix 'u' is passed to
NeutronException in python 2, string subsitution will fail.
In python 2, multibyte string without 'u' prefix is encoded into bytes.
As a result a string substitution in NeutronException.__init__ will fail.

Change-Id: I1aa08b69fe119087a7a49fda768a24f85f0e7c76
Closes-Bug: #1235228
2016-12-15 09:09:18 +00:00
Akihiro Motoki
d0e50b8b90 Use six.python_2_unicode_compatible for NeutronException.__str__
The definition of __str__ is different between py2 and py3.
__str__ should return a byte stream to make print(exc) work
in python2, but __str__ should return string type in python3.
six.python_2_unicode_compatible sets up __str__ and __unicode__
approriately.

Change-Id: I6c85ca8c4e6f86450ee390db81e3aa101293b846
Related-Bug: #1235228
2016-01-05 08:39:25 +09:00