With this change, all Horizon unit tests pass on Python 3.4.
Changes:
* vpn/tests.py, firewalls/tests.py: Replace reverse_lazy() with
reverse() to get a regular Python string. The lazy object caused
failures on Python 3.
* routers/tests.py: Decode HTTP body to get Unicode on Python 3. It
works also on Python 2.
* neutron.py: replace a/b with a//b to get an integer on Python 3.
* network_tests.py: remove useless copy.deepcopy() which caused a
recursion error on Python 3.
* metadata_defs/tests.py: expect a different JSON error message on
Python 3.
* tox.ini: remove openstack_dashboard whitelist, all unit tests now
pass on Python 3 ;-)
Partial-Implements: blueprint porting-python3
Change-Id: I7b4f036fc86b66c92cccafe6938a906045f03186
On Python 3, Content-Disposition header is encoded using MIME format
'=?utf-8?b?...?='. Use decode_header() of email.header to decode it.
Handle also Unicode/bytes issues on this header.
tox.ini: Add openstack_dashboard.dashboards.project.containers to
Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: Id5898ee5494d019d1397ed3fa5e0a715e9a0393f
Stop using deprecated data_type_singular and data_type_plural:
replace them with action_present and action_past properties to handle
correctly singular/plural.
Partial-Implements: blueprint porting-python3
Change-Id: I4fc3acf2da27348f371d3e387588baafc286605a
* Convert reverse_lazy() to get a regular string, not a lazy()
object. lazy objects lack methods like .encode().
* don't compare None with int: test if delay is None before comparing
it to timeout.
* tox.ini: add openstack_dashboard.dashboards.project.loadbalancers
to Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: Icd2d6db1aae79a9584af1760e21f733d8f5f7f7d
This adds a failing Django 1.9 tox env. This will be followed by a
non-voting Jenkins job to show the tests failing, and then a follow up
patch to make them pass.
Change-Id: I0534746360266e4a99e014d69ac19ab2d5b44a83
Partially-Implements: blueprint drop-dj17
The best practice in Python is not to use mutable object (i.e. list,
dictionary, or instances of most classes) as value of default
argument (see https://goo.gl/Kwhg0T). A hacking rule to enforce this
practice is added as well.
The patch was inspired by CR https://review.openstack.org/#/c/198465/
and took most of its code from it as well. That's why original
copyrights are kept.
Closes-Bug: #1471349
Change-Id: Ia77b1736dbc3d4e28ff2d2c3424e9cfcaefa5077
* Use NamedTemporaryFile instead of TemporaryFile because we must
have a name which is a text on Python 3. Otherwise, the test fails.
On Python 3, TemporaryFile uses an integer for the file name, the
file descriptor.
* Replace filter() and map() with list comprehensions to get a list
on Python 3.
* On Python 3, temporary files are open in binary mode so write a
byte string instead of a text string.
* tox.ini: enable all image tests on Python 3.
Partial-Implements: blueprint porting-python3
Change-Id: Ice7f119c040bbddeda10ed45d137bb7851764b8d
Replace json.loads() with oslo_serialization.jsonutils.loads() to
accept bytes (HTTP body). jsonutils.loads() decodes the HTTP body
from UTF-8.
tox.ini: add network_topology tests to Python 3.
Change-Id: I9f65d63e3ed54525e52b92b7728b78cf1b9e7bb5
* On Python 3, the pretty JSON output doesn't add space before newline.
* CreateStackForm: don't compare str to int, it raises a TypeError on
Python 3. Instead, use MinLength already converted to int.
* tox.ini: enable all stacks on Python 3.
Partial-Implements: blueprint porting-python3
Change-Id: I20cd9e83720cc3974973bec5471864f0ffc00716
* Decode HTTP body from UTF-8 to get text on Python 3
* tox.ini: add routers tests to Python 3
Partial-Implements: blueprint porting-python3
Change-Id: Idc93818c4b62f782035604090b7c6fda459cf6fa
* Fix division: replace a/b with a//b to get integers
* test_clean_file_upload_form_invalid_data(): use a byte string, not
an unicode string for the test. The test ensures that decoding from
UTF-8 fails.
* quotas: replace filter() with a list-comprehesion to get a list on
Python 3.
* tox.ini: add the following tests to Python 3.4
- openstack_dashboard.dashboards.project.instances.tests
- openstack_dashboard.test.tests.quotas
* tox.ini: add also
--exclude-dir=openstack_dashboard/test/integration_tests to
openstack_dashboard tests on Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: I7caed713222b50ffec431155e6f91b543f7df466
Since tox 1.5, commands outside the virtual environment must be
explicitly listed in whitelist_externals. Without that, some commands
emit the warning:
WARNING:test command found but not installed in testenv
cmd: /bin/bash
env: ...
See also the whitelist_externals envconfig setting.
Change-Id: Iad1f623defbb32dafb5bad3613cec7a8409e2b2c
* DataTable: don't try to decode Unicode from UTF-8. Only decode on
Python 2.
* Use oslo_serialization.jsonutils.dump_as_bytes() to encode JSON
as bytes.
* Use oslo_serialization.jsonutils.loads() instead of json.loads() to
accept bytes string as input. On Python 3, json.loads() only
accepts Unicode string.
* Fix unit tests: HTTP body type is bytes.
* Container tests: use a named temporary file, the function handling
the filename fails. On Python 3, TemporaryFile() uses a number for
the filename: the file descriptor.
* Don't encode filename to UTF-8 on Python 3, keep Unicode.
* tox.ini: add 2 admin tests on Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: Ib7e2cb17f20474590fac18faf8116131692ad694
Run the unicode operation of the sixer tool on openstack_dashboard/
directory.
tox.ini: Add the following tests to Python 3.4:
* openstack_dashboard.contrib.sahara.content.data_processing.data_sources.tests
* openstack_dashboard.contrib.sahara.content.data_processing.job_binaries.tests
* openstack_dashboard.contrib.sahara.content.data_processing.jobs.tests
* openstack_dashboard.dashboards.project.networks.tests
Partial-Implements: blueprint porting-python3
Change-Id: Ibfe52ccbccc30e6b1d59137c68942c9860805397
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
Replace filter() with list-comprehension when a list is expected. On
Python 3, filter() returns an iterator, not a list.
tox.ini: add openstack admin volume tests to Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: Id99124bf0ef5549c596d94f5d10ab5f88a4e200a
* XSS check: don't check the exact HTML output because the attributes
of the <a> tag are rendered on a different order depending on the
hash function. On Python 3, the hash function is now randomized.
* Replace table.columns.values() with list(table.columns.values())
to get a list on Python 3.
* WorkflowsTests: cast the HTTP response to bytes(), not to str().
On Python 2, bytes is str so the test pass on Python 2 and Python 3.
* tox.ini: run all Horizon tests on Python 3 (but keep the whitelist
for the openstack dashboard)
Partial-Implements: blueprint porting-python3
Change-Id: I19c5710fe53c6cdd3814a1615cef7b27339c444c
Add a json attribute to CreatedResponse and JSONResponse of
openstack_dashboard.api.rest.utils.
This patch changes unit tests: they now compare deserialized JSON
data instead of comparing the serialized JSON data which depends on
the exact hash function
This change makes the code more readable, but it was written to port
openstack_dashboard to Python 3. On Python 3, the hash function is
now randomized by default, so dictionary items are serialized in a
random order by JSON. Moreover, the hash function is different on
Python 2 and Python 3, so setting PYTHONHASHSEED=0 in tox.ini is not
enough to have a reliable JSON serialized ouput in all cases.
Fix also NaNJSONEncoder: On Python 3, don't try to decode bytes from
the encoder encoding, since the JSON encoder has no more encoding on
Python 3: it produces an Unicode string.
Partial-Implements: blueprint porting-python3
Change-Id: I8503ee530d4122b2ce733d02023454796934c8e6
Co-Authored-By: Richard Jones <r1chardj0n3s@gmail.com>
* get_cells(): cast dict.values() to a list to return a list
on Python 3. On Python 3, dict.values() now returns a view.
* Replace dict.values()[0] with list(dict.values())[0]
* get_tabs(): replace filter() with a list-comprehension to return a
list on Python 3
* tox.ini: add horizon.test.tests.tabs to Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: I0ebcaa5f7b283d04425ce7201087220376257d41
* Fix AngularGettextHTMLParser constructor: call the constructor of the
right parent class.
* tox.ini: Add horizon.test.tests.babel_extract_angular to Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: I020f9655baf18326f3752b82a8c3bf385c8e1e24
* Replace dict.values()[0] with list(dict.values())[0]. On Python 3,
dict.values() returns a view which is not indexable.
* tox.ini: add the following tests to Python 3.4
- openstack_dashboard.dashboards.identity.users
- openstack_dashboard.test.api_tests.glance_tests
- openstack_dashboard.test.api_tests.heat_tests
Partial-Implements: blueprint porting-python3
Change-Id: I68dbe85750399263938b1bf5a342fbb90de83861
* Fix CsvDataMixin: replace map() with a list-comprehension to get a
list on Python 3, because the sequence is consumed more than once. On
Python 3, map() returns an iterator which can only be consumed once.
* tox.ini: add openstack_dashboard.dashboards.project.overview.tests
to Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: I9fb71a0b45c1e0a083c91476970938df5c649806
* Use literal octal number syntax instead of the oct() function. The
oct() function gives a different result on Python 2 and Python 3
(Python 3 uses the "0o" prefix, not Python 2).
* format_value() explicitly cast the result to float. It's needed on
Python 3 to cast a Decimal to float, because round(Decimal) returns a
Decimal.
* tox.ini: run all horizon.test.tests.utils tests on Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: Ifd7c0e16ea85b691b81659acb010e9eb6f982d13
The Python 2 assertItemsEqual() method was renamed to
assertCountEqual() in Python 3, and assertNotRegexpMatches() was
renamed to assertNotRegex(). Add aliases in
horizon.test.helpers.TestCase.
tox.ini: add horizon.test.tests.messages to Python 3.4.
Partial-Implements: blueprint porting-python3
Change-Id: If7abd51fd3559a5ab32d433c6dc3476bd678b2bf
* Replace registry.keys() with list(registry). On Python 3,
dict.keys() now returns a dictionary view, whereas we need a copy
of keys here.
* CustomPanelTests: load horizon.test.customization.cust_test1
configuration after calling setUp() and force a reload of URLs.
BaseHorizonTests.setUp() keeps original panels for each dashboard
to be able to restore them in tearDown().
* tox.ini: run all horizon.test.tests.base tests on Python 3.4, not
only horizon.test.tests.base.GetUserHomeTests.
Without the CustomPanelTests change, 3 tests fail with NoReverseMatch
when running the base test on Python 2 with the following command (in
the .tox/py27/ virtual environment):
python manage.py test --settings=horizon.test.settings \
horizon.test.tests.base
Partial-Implements: blueprint porting-python3
Change-Id: Ibdd5fcaa863c6eaae4a519f3d1b56034f0ef9708
From django V1.9 django.utils.datastructures.SortedDict
will be removed and it is deprecated in V1.7.
The similar functionality is added in collections.OrderedDict
from python 2.7.
Horizon code also should avoid the SortedDict class and
start using the OrderedDict class.
This patch replacing the SortedDict with OrderedDict.
Change-Id: I8dfcf7c29fc49b6215451f160cf7a951bf11b5ad
Closes-Bug: #1492270
HTTP body type is bytes: encode expected string to get bytes in the
unit test.
Change-Id: I3fa03012c3ca9005dc2fae94054b3ef5f58098f0
Partial-Implements: blueprint porting-python3
* load_template_source(): use io.open() with an encoding instead of
open(), to have the same behaviour on Python 2 and Python 3
* assertRedirectsNoFollow(): remove an useless assertion on the
response status code which is already tested a few lines below. The
assertion used code/100 which returns a float on Python 3, whereas
an int was expected.
* add_logout_reason(): don't encode reason to UTF-8 on Python 3
* tox.ini: add openstack_dashboard.dashboards.settings.password to
Python 3.4
Partial-Implements: blueprint porting-python3
Change-Id: Iff8997917b5d812952150b2abe89ddd12deab0c0
HTTP body type is bytes: encode expected text to UTF-8 to get bytes.
Partial-Implements: blueprint porting-python3
Change-Id: I5436728aad256a650511d8b206ac2916c2ea574e