Import i18n functions from module directly and do not use
global module variables like _ = i18n._. It makes code shorter
and cleaner. It also to detect cases when these functions are not
used in module.
Change-Id: Iaa593ac1f2dd15cbcad049bef6ba68f1cfa610da
To resolve "db type could not be determined" when running tox
for the first time py34 environment need to laucnhed before py27.
Change-Id: I572d129860119c78134a98f3bea814e6c9756aad
Closes-Bug: #1489059
Set up automated bandit checks using tox. These tests are intended to be
eventually suitable as automated gate tests.
Currently, several tests are disabled (and labeled with a TODO to enable
them). A future commit for each test will enable that test, fix all
associated false positives, and fix all associated real positives.
Change-Id: I290992be027eac180b3a0dfcf601465079c2915c
Partial-bug: 1511862
This patch fixes some common issues that prevented
glance.tests.unit.v1.test_registry_client from working with Python 3.
Change-Id: I27e8dbdd1075afe1be679a2d1573e4484591582d
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Some issues:
- the usual str vs bytes thing;
- 'reload' no longer exists in Python 3, but is available through six;
- 'min_ram' and 'min_disk' have to be integers because Python 3 cannot
compare integers and strings.
Change-Id: I8a65da8bad7ba14b6af32348c30366d0db49212c
Two issues here:
- jsonutils.dump_as_bytes should be used since request.body needs to be
set to bytes;
- in Python 3, calling "del o[:]" makes us end up in __delslice__ with
"i" and "j" being None, hence the little trick in glance/location.py.
Change-Id: Iff191305ab55f67801183127077fc8ae9738e763
This adds the constraints factor to the base section and duplicates
the sections required for CI with -constraints as tox does not
currently support factors in sections. Work towards enabling factor
support in sections is currently stalled, as such we will need to
duplicate sections adding -constraints to facilitate running sections
with the constrained install_command.
Implements Blueprint: Requirements-Management
Change-Id: Ibbeabdf65c1405bf4d35e21375636dcc4583bbc2
* urlsafe_b64decode(): on Python 3, decode from ASCII to get Unicode
string.
* urlsafe_decrypt(): encode Unicode to UTF-8.
* in some loops, copy dictionary keys or items because the dictionary
is modified in the loop body.
* test_api: use byte string for image content, not Unicode
* test_registry_api: HTTP body type is bytes, use byte strings and
jsonutils.dump_as_bytes(), instead of native strings and
jsonutils.dumps()
* tox.ini: add glance.tests.unit.v1.test_registry_api to Python 3.4
Change-Id: Ib9d18dce6e5728b9adf094b5aae64a86a3fea71a
* Catch also binascii.Error when decoding Base64: Python 3 raises
binascii.Error, not TypeError.
* Replace base64.b64decode() with base64.decode_as_bytes() to get
accept also Unicode.
* verify_signature(): encode checksum_hash to UTF-8 if it's Unicode.
* Fix test_signature_utils: use byte strings
* tox.ini: add glance.tests.unit.common.test_signature_utils
Change-Id: I386892f3e28f9454a438e414730318ec3f771342
* Decode HTTP body from UTF-8 to get Unicode on Python 3. The test
still works on Python 2.
* tox.ini: add test_cache_manage to Python 3.4.
Change-Id: I637732cb06b7ae30853b35d2a83aa85f643fd43b
* Replace filter() with list-comprehension to get a list on Python 3.
* HTTP body type is bytes: use byte strings for body.
Change-Id: Ia7fba4b075cdedd4581e4e8503f5220c1e6198d7
* Replace exc.message with six.text_type(exc). The message attribute
of exceptions was removed in Python 3.
* set_image_data(): replace "isinstance(data_iter, file)" with
"hasattr(data_iter, 'close')". The file type is gone in Python 3,
use duck-typing instead to check for the close() method.
* Use bytes instead of Unicode strings for image content. Replace
cStringIO() with BytesIO().
* Fix data iterator: use a list of strings instead of a string.
* tox.ini: add the following tests to Python 3.4
- glance.tests.unit.async.flows.test_convert
- glance.tests.unit.async.flows.test_import
- glance.tests.unit.async.flows.test_introspect
- glance.tests.unit.async.test_taskflow_executor
Change-Id: I885e11c0da1a264456fdeb2bff54dcfd3acfd193
* rpc: allow also exceptions from the builtins module. On Python 3,
builtin exceptions are part of the builtins module. The exceptions
module was removed in Python 3.
* Fix usage of reraise(): translate_exception() returns an instance
which is the second parameter of the reraise() function, not the
first parameter. The first parameter is the exception type.
* test_rpc: add json_dump_as_bytes() helper to serialize JSON as
bytes.
* JSONRequestDeserializer: don't compare None to int, it raises a
TypeError on Python 3.
* Fix Unicode versus bytes issues: HTTP body type is bytes. Encode
JSON to UTF-8 for example. Replace StringIO with BytesIO.
* Replace filter() with a list-comprehension to get a list on
Python 3.
* test_client, test_image_cache_client: use bytes for HTTP body.
* tox.ini: add glance.tests.unit.common.test_rpc to Python 3.
Change-Id: I9960d6a810375474f89c1788b7016a8fbb0770e0
pbr's reflection pulls in all the runtime requirements automatically -
the only reason to have the txt file explicitly listed is to permit
things that can't be reflected like url references - which we've
stopped using anyway.
Change-Id: I81b7ac268d5c007f74a2ab1dce94da41d6d75c7b
* CooperativeReader: buffer is a byte string, use b'' syntax
and use bytes() instead of str().
* Don't compare None to int, it raises a TypeError on Python 3.
* Use str[i:i+1] to get a substring from a byte string. On Python 3,
str[i] now returns an integer for byte strings.
* tox.ini: add glance.tests.unit.common.test_utils to Python 3.4
Change-Id: Ie678555ffd8ac48913f9bf08ac674d1c643bec29
* StoreLocations: add a __eq__() method, Python 3 doesn't use __cmp__()
anymore
* Fix StoreLocations.__delitem__(): Python 3 now calls it with a slice
for "del locations[a:b]" instead of calling __delslice__().
* Fix test_store_location: mark byte strinsg with b'...' prefix.
* tox.ini: add test_store_location to Python 3.4
Change-Id: Ibe8dac3d442ee08ae6b347e256947b6b9c5224ae