Port horizon base tests to Python 3
* 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
This commit is contained in:
parent
749e436c63
commit
46628f0cb1
@ -87,11 +87,11 @@ class BaseHorizonTests(test.TestCase):
|
|||||||
# hasn't happened yet.
|
# hasn't happened yet.
|
||||||
base.Horizon._urls()
|
base.Horizon._urls()
|
||||||
# Store our original dashboards
|
# Store our original dashboards
|
||||||
self._discovered_dashboards = base.Horizon._registry.keys()
|
self._discovered_dashboards = list(base.Horizon._registry)
|
||||||
# Gather up and store our original panels for each dashboard
|
# Gather up and store our original panels for each dashboard
|
||||||
self._discovered_panels = {}
|
self._discovered_panels = {}
|
||||||
for dash in self._discovered_dashboards:
|
for dash in self._discovered_dashboards:
|
||||||
panels = base.Horizon._registry[dash]._registry.keys()
|
panels = list(base.Horizon._registry[dash]._registry)
|
||||||
self._discovered_panels[dash] = panels
|
self._discovered_panels[dash] = panels
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -372,11 +372,12 @@ class CustomPanelTests(BaseHorizonTests):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(CustomPanelTests, self).setUp()
|
||||||
settings.HORIZON_CONFIG['customization_module'] = \
|
settings.HORIZON_CONFIG['customization_module'] = \
|
||||||
'horizon.test.customization.cust_test1'
|
'horizon.test.customization.cust_test1'
|
||||||
# refresh config
|
# refresh config
|
||||||
conf.HORIZON_CONFIG._setup()
|
conf.HORIZON_CONFIG._setup()
|
||||||
super(CustomPanelTests, self).setUp()
|
self._reload_urls()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Restore dash
|
# Restore dash
|
||||||
@ -476,11 +477,11 @@ class RbacHorizonTests(test.TestCase):
|
|||||||
# hasn't happened yet.
|
# hasn't happened yet.
|
||||||
base.Horizon._urls()
|
base.Horizon._urls()
|
||||||
# Store our original dashboards
|
# Store our original dashboards
|
||||||
self._discovered_dashboards = base.Horizon._registry.keys()
|
self._discovered_dashboards = list(base.Horizon._registry)
|
||||||
# Gather up and store our original panels for each dashboard
|
# Gather up and store our original panels for each dashboard
|
||||||
self._discovered_panels = {}
|
self._discovered_panels = {}
|
||||||
for dash in self._discovered_dashboards:
|
for dash in self._discovered_dashboards:
|
||||||
panels = base.Horizon._registry[dash]._registry.keys()
|
panels = list(base.Horizon._registry[dash]._registry)
|
||||||
self._discovered_panels[dash] = panels
|
self._discovered_panels[dash] = panels
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
2
tox.ini
2
tox.ini
@ -22,7 +22,7 @@ commands = /bin/bash run_tests.sh -N --no-pep8 {posargs}
|
|||||||
[testenv:py34]
|
[testenv:py34]
|
||||||
commands =
|
commands =
|
||||||
python manage.py test --settings=horizon.test.settings \
|
python manage.py test --settings=horizon.test.settings \
|
||||||
horizon.test.tests.base.GetUserHomeTests \
|
horizon.test.tests.base \
|
||||||
horizon.test.tests.forms \
|
horizon.test.tests.forms \
|
||||||
horizon.test.tests.middleware \
|
horizon.test.tests.middleware \
|
||||||
horizon.test.tests.tables.DataTableViewTests \
|
horizon.test.tests.tables.DataTableViewTests \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user