From 74f4642a2c03ed7bcc28fd09e717c719bff360b6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 9 Apr 2015 07:35:33 +0200 Subject: [PATCH] Fix lint. --- tests/misc/test_split.py | 19 ++++++++++++++----- tests/utils/test_qtutils.py | 11 ++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/misc/test_split.py b/tests/misc/test_split.py index 340fe6fb1..e926368e0 100644 --- a/tests/misc/test_split.py +++ b/tests/misc/test_split.py @@ -107,24 +107,28 @@ test_data_lines = test_data.strip().splitlines() class TestSplit: + """Test split.""" @pytest.mark.parametrize('cmd, out', - [case.split('/')[:-2] for case in test_data_lines]) + [case.split('/')[:-2] + for case in test_data_lines]) def test_split(self, cmd, out): """Test splitting.""" items = split.split(cmd) assert items == out.split('|') @pytest.mark.parametrize('cmd', - [case.split('/')[0] for case in test_data_lines]) + [case.split('/')[0] + for case in test_data_lines]) def test_split_keep_original(self, cmd): """Test if splitting with keep=True yields the original string.""" items = split.split(cmd, keep=True) assert ''.join(items) == cmd @pytest.mark.parametrize('cmd, _mid, out', - [case.split('/')[:-1] for case in test_data_lines]) + [case.split('/')[:-1] + for case in test_data_lines]) def test_split_keep(self, cmd, _mid, out): """Test splitting with keep=True.""" items = split.split(cmd, keep=True) @@ -132,6 +136,7 @@ class TestSplit: class TestSimpleSplit: + """Test simple_split.""" TESTS = { @@ -150,12 +155,16 @@ class TestSimpleSplit: def test_str_split_maxsplit_1(self): """Test if the behavior matches str.split with maxsplit=1.""" s = "foo bar baz" - assert split.simple_split(s, maxsplit=1) == s.rstrip().split(maxsplit=1) + actual = split.simple_split(s, maxsplit=1) + expected = s.rstrip().split(maxsplit=1) + assert actual == expected def test_str_split_maxsplit_0(self): """Test if the behavior matches str.split with maxsplit=0.""" s = " foo bar baz " - assert split.simple_split(s, maxsplit=0) == s.rstrip().split(maxsplit=0) + actual = split.simple_split(s, maxsplit=0) + expected = s.rstrip().split(maxsplit=0) + assert actual == expected @pytest.mark.parametrize('test, expected', TESTS.items()) def test_split_keep(self, test, expected): diff --git a/tests/utils/test_qtutils.py b/tests/utils/test_qtutils.py index b88caada6..e3c5478f8 100644 --- a/tests/utils/test_qtutils.py +++ b/tests/utils/test_qtutils.py @@ -28,6 +28,7 @@ from qutebrowser.utils import qtutils class TestCheckOverflow: + """Test check_overflow. Class attributes: @@ -66,8 +67,8 @@ class TestCheckOverflow: qtutils.check_overflow(val, ctype) @pytest.mark.parametrize('ctype, val', - [(ctype, val) for ctype, vals in BAD_VALUES.items() - for (val, _) in vals]) + [(ctype, val) for ctype, vals in + BAD_VALUES.items() for (val, _) in vals]) def test_bad_values_fatal(self, ctype, val): """Test values which are outside bounds with fatal=True.""" with pytest.raises(OverflowError): @@ -83,12 +84,16 @@ class TestCheckOverflow: class TestGetQtArgs: + """Tests for get_args.""" @pytest.fixture def parser(self, mocker): + """Fixture to provide an argparser. + + Monkey-patches .exit() of the argparser so it doesn't exit on errors. + """ parser = qutebrowser.get_argparser() - # monkey-patch .exit() of the argparser so it doesn't exit. mocker.patch.object(parser, 'exit', side_effect=Exception) return parser