From 65dac7f4124e08f3119b86a3cc1439454ba4d608 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 28 Aug 2015 17:22:49 +0200 Subject: [PATCH] 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 --- horizon/tables/base.py | 6 +++--- horizon/tabs/base.py | 2 +- tox.ini | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index a0c70facd..4983c44cc 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -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 diff --git a/horizon/tabs/base.py b/horizon/tabs/base.py index 94d05f216..7a214967e 100644 --- a/horizon/tabs/base.py +++ b/horizon/tabs/base.py @@ -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. diff --git a/tox.ini b/tox.ini index 1c31f2e7b..e933eecda 100644 --- a/tox.ini +++ b/tox.ini @@ -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 \