Skip to content
Snippets Groups Projects
Commit e55fa115 authored by Adam Williamson's avatar Adam Williamson Committed by Adam Williamson
Browse files

test_listing: add test_list_empty to enhance coverage


This covers the `if not data: raise StopIteration` bit of
`load_chunk`.

Signed-off-by: default avatarAdam Williamson <awilliam@redhat.com>
parent e78c1686
No related branches found
No related tags found
No related merge requests found
......@@ -183,6 +183,18 @@ class TestList(unittest.TestCase):
assert len(vals) == 3
assert type(vals[0]) == tuple
@mock.patch('mwclient.client.Site')
def test_list_empty(self, mock_site):
# Test that we handle an empty response from get correctly
# (stop iterating)
lst = List(mock_site, 'allpages', 'ap', limit=2,
return_values=('title', 'ns'))
mock_site.get.side_effect = [{}]
vals = [x for x in lst]
assert len(vals) == 0
@mock.patch('mwclient.client.Site')
def test_generator_list(self, mock_site):
# Test that the GeneratorList yields Page objects
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment