Module: check_mk
Branch: master
Commit: dc8a321c0ef7c301177beae57807f4a9a0ce57fb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dc8a321c0ef7c3…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 10 16:10:19 2018 +0100
Make pylint and mypy happy for test_table.
Change-Id: I93401b2fdfc802defb2c7792b3e5f113cf649029
---
tests/unit/cmk/gui/test_table.py | 41 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/tests/unit/cmk/gui/test_table.py b/tests/unit/cmk/gui/test_table.py
index 87c80cc..3fa632d 100644
--- a/tests/unit/cmk/gui/test_table.py
+++ b/tests/unit/cmk/gui/test_table.py
@@ -1,22 +1,19 @@
#!/usr/bin/env python
import re
-from bs4 import BeautifulSoup as bs
-import __builtin__
-import pytest
-from tools import compare_html, gentest, compare_and_empty, bcolors
+from bs4 import BeautifulSoup as bs # type: ignore
+import pytest # type: ignore
+import six
from cmk.gui.i18n import _
-import cmk.gui.htmllib as htmlllib
-import cmk.gui.http as http
import cmk.gui.table as table
from cmk.gui.table import Table
from cmk.gui.globals import html
-
+from tools import compare_html
def read_out_simple_table(text):
- assert type(text) in [ str, unicode ]
+ assert isinstance(text, six.string_types)
# Get the contents of the table as a list of lists
data = []
for row in bs(text, 'html5lib').findAll('tr'):
@@ -43,10 +40,10 @@ def read_out_csv(text, separator):
def test_basic(register_builtin_html):
- id = 0
+ table_id = 0
title = " TEST "
- table = Table(id, title, searchable=False, sortable=False)
+ table = Table(table_id, title, searchable=False, sortable=False)
table.row()
table.cell("A", "1")
table.cell("B", "2")
@@ -60,10 +57,10 @@ def test_basic(register_builtin_html):
def test_plug(register_builtin_html):
- id = 0
+ table_id = 0
title = " TEST "
- table = Table(id, title, searchable=False, sortable=False)
+ table = Table(table_id, title, searchable=False, sortable=False)
table.row()
table.cell("A", "1")
html.write("a")
@@ -88,8 +85,8 @@ def test_context(register_builtin_html):
with table.open_table(table_id=table_id, searchable=False, sortable=False):
for row in rows:
table.row()
- for i in range(len(header)):
- table.cell(_(header[i]), row[i])
+ for h, r in zip(header, row):
+ table.cell(_(h), r)
written_text = "".join(html.response.flush_output())
data = read_out_simple_table(written_text)
@@ -99,15 +96,15 @@ def test_context(register_builtin_html):
def test_nesting(register_builtin_html):
- id = 0
+ table_id = 0
title = " TEST "
- table = Table(id, title, searchable=False, sortable=False)
+ table = Table(table_id, title, searchable=False, sortable=False)
table.row()
table.cell("A", "1")
table.cell("B", "")
- t2 = Table(id+1, title+"2", searchable=False, sortable=False)
+ t2 = Table(table_id+1, title+"2", searchable=False, sortable=False)
t2.row()
t2.cell("_", "+")
t2.cell("|", "-")
@@ -131,14 +128,14 @@ def test_nesting(register_builtin_html):
def test_nesting_context(register_builtin_html):
- id = 0
+ table_id = 0
title = " TEST "
- with table.open_table(table_id=id, title=title, searchable=False, sortable=False):
+ with table.open_table(table_id=table_id, title=title, searchable=False,
sortable=False):
table.row()
table.cell("A", "1")
table.cell("B", "")
- with table.open_table(id+1, title+"2", searchable=False,
sortable=False):
+ with table.open_table(table_id+1, title+"2", searchable=False,
sortable=False):
table.row()
table.cell("_", "+")
table.cell("|", "-")
@@ -190,8 +187,8 @@ def test_table_cubical(register_builtin_html, monkeypatch, sortable,
searchable,
output_format = output_format)
for row in rows:
table.row()
- for i in range(len(header)):
- table.cell(_(header[i]), row[i])
+ for h, r in zip(header, row):
+ table.cell(_(h), r)
table.end()
# Get generated html