Port horizon tabs tests to Python 3

* 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
This commit is contained in:
Victor Stinner 2015-08-28 17:22:49 +02:00
parent 9e09cfab2e
commit 65dac7f412
3 changed files with 5 additions and 4 deletions

View File

@ -442,7 +442,7 @@ class Column(html.HTMLElement):
summation_function = self.summation_methods[self.summation]
data = [self.get_raw_data(datum) for datum in self.table.data]
data = filter(lambda datum: datum is not None, data)
data = [raw_data for raw_data in data if raw_data is not None]
if len(data):
try:
@ -605,7 +605,7 @@ class Row(html.HTMLElement):
def get_cells(self):
"""Returns the bound cells for this row in order."""
return self.cells.values()
return list(self.cells.values())
def get_ajax_update_url(self):
table_url = self.table.get_absolute_url()
@ -1396,7 +1396,7 @@ class DataTable(object):
"""hide checkbox column if no current table action is allowed."""
if not self.multi_select:
return
select_column = self.columns.values()[0]
select_column = list(self.columns.values())[0]
# Try to find if the hidden class need to be
# removed or added based on visible flag.
hidden_found = 'hidden' in select_column.classes

View File

@ -177,7 +177,7 @@ class TabGroup(html.HTMLElement):
def get_tabs(self):
"""Returns a list of the allowed tabs for this tab group."""
return filter(lambda tab: tab._allowed, self._tabs.values())
return [tab for tab in self._tabs.values() if tab._allowed]
def get_tab(self, tab_name, allow_disabled=False):
"""Returns a specific tab from this tab group.

View File

@ -27,6 +27,7 @@ commands =
horizon.test.tests.messages \
horizon.test.tests.middleware \
horizon.test.tests.tables.DataTableViewTests \
horizon.test.tests.tabs \
horizon.test.tests.templatetags \
horizon.test.tests.test_file_discovery \
horizon.test.tests.utils.FiltersTests \