`unittest.assertRaises` is almost always lazy, and should be avoided.
The only desirable use of `unittest.assertRaises` is:
```lang=python
with self.assertRaises(ValueError) as cm:
self.assertEqual(cm.exception, '.....')
```
`unitest.assertRaisesRegex` has an extra parameter to check the exception message, and should be used instead. By checking the exception message, the unit test verifies that the exception is precisely the one which was expected, rather than only of the same type as expected.
pywikibot has 33 unit test modules that use `assertRaises` and need upgrading:
```
$ git grep 'assertRaises(' tests | grep -v 'with.* as ' | cut -d ':' -f 1 | sort -u
33
$ git grep 'assertRaises(' tests | grep -v 'with.* as '
tests/api_tests.py: self.assertRaises(api.APIMWException, req.submit)
tests/api_tests.py: self.assertRaises(api.APIMWException, req.submit)
tests/api_tests.py: self.assertRaises(api.APIMWException, req.submit)
tests/api_tests.py: self.assertRaises(KeyError, pi.__getitem__, 'foobar')
tests/api_tests.py: self.assertRaises(KeyError, pi.__getitem__, 'foobar+foobar')
tests/api_tests.py: self.assertRaises(KeyError, pi.__getitem__, 'query+foobar')
tests/api_tests.py: self.assertRaises(KeyError, pi.submodules, 'edit')
tests/api_tests.py: self.assertRaises(KeyError, options.__setitem__, 'invalid_name', True)
tests/api_tests.py: self.assertRaises(ValueError, options.__setitem__, 'anon', 'invalid_value')
tests/api_tests.py: self.assertRaises(KeyError, options._set_site, self.get_site(),
tests/api_tests.py: self.assertRaises(TypeError, options._set_site, self.get_site(),
tests/api_tests.py: self.assertRaises(AssertionError, self.gen.set_namespace, 0)
tests/api_tests.py: self.assertRaises(AssertionError, self.gen.set_namespace, 1)
tests/api_tests.py: self.assertRaises(AssertionError, self.gen.set_namespace, None)
tests/api_tests.py: self.assertRaises(TypeError, self.gen.set_namespace, None)
tests/api_tests.py: self.assertRaises(pywikibot.NoUsername, req.submit)
tests/api_tests.py: self.assertRaises(api.APIError, req.submit)
tests/api_tests.py: self.assertRaises(pywikibot.NoUsername, req.submit)
tests/api_tests.py: self.assertRaises(api.APIError, req.submit)
tests/archivebot_tests.py: self.assertRaises(archivebot.MalformedConfigError, archivebot.str2time, '4000@')
tests/archivebot_tests.py: self.assertRaises(archivebot.MalformedConfigError, archivebot.str2time, '$1')
tests/bot_tests.py: self.assertRaises(StopIteration, next, self._page_iter)
tests/bot_tests.py: with self.assertRaises(AttributeError):
tests/bot_tests.py: with self.assertRaises(ValueError):
tests/bot_tests.py: with self.assertRaises(ValueError):
tests/bot_tests.py: self.assertRaises(ValueError, self.bot.run)
tests/category_tests.py: self.assertRaises(ValueError, pywikibot.Category, site, 'Wikipedia:Test')
tests/category_tests.py: self.assertRaises(pywikibot.IsNotRedirectPage,
tests/category_tests.py: self.assertRaises(ValueError, pywikibot.Category, site, 'Talk:Foo')
tests/diff_tests.py: self.assertRaises(ImportError, html_comparator, '')
tests/djvu_tests.py: self.assertRaises(IOError, DjVuFile, self.file_djvu_not_existing)
tests/djvu_tests.py: self.assertRaises(ValueError, djvu.get_page, 100)
tests/djvu_tests.py: self.assertRaises(ValueError, djvu.get_page, 100)
tests/dry_site_tests.py: self.assertRaises(UnknownSite, self.call_this_user_req_function, args, kwargs)
tests/dry_site_tests.py: self.assertRaises(NotImplementedError, self.too_new)
tests/edit_failure_tests.py: self.assertRaises(LockedPage, page.save)
tests/edit_failure_tests.py: self.assertRaises(PageCreatedConflict, page.save, createonly=True)
tests/edit_failure_tests.py: self.assertRaises(NoCreateError, page.save, nocreate=True)
tests/edit_failure_tests.py: self.assertRaises(Error, mysite.movepage,
tests/edit_failure_tests.py: self.assertRaises(NoPage, mysite.movepage,
tests/edit_failure_tests.py: self.assertRaises(pywikibot.PageNotSaved, item.save)
tests/family_tests.py: self.assertRaises(UnknownFamily, Family.load, 'unknown')
tests/family_tests.py: self.assertRaises(UnknownFamily, family.__eq__, other)
tests/family_tests.py: self.assertRaises(TypeError, family.obsolete.update, {})
tests/family_tests.py: self.assertRaises(TypeError, family.obsolete.__setitem__, 'a', 'b')
tests/family_tests.py: self.assertRaises(TypeError, family.__setattr__, 'obsolete',
tests/family_tests.py: self.assertRaises(ValueError, f.from_url,
tests/family_tests.py: self.assertRaises(UnknownFamily, pywikibot.site.Family, 'unknown',
tests/family_tests.py: self.assertRaises(UnknownFamily, pywikibot.site.Family, 'unknown')
tests/file_tests.py: self.assertRaises(pywikibot.NoPage, itwp_file.get)
tests/file_tests.py: self.assertRaises(pywikibot.NoPage, commons_file.fileIsShared)
tests/file_tests.py: self.assertRaises(pywikibot.NoPage, commons_file.fileUrl)
tests/file_tests.py: self.assertRaises(pywikibot.NoPage, commons_file.get)
tests/file_tests.py: with self.assertRaises(pywikibot.NoPage):
tests/file_tests.py: with self.assertRaises(pywikibot.PageRelatedError):
tests/flow_edit_tests.py: self.assertRaises(LockedPage, topic.reply, content, 'wikitext')
tests/flow_edit_tests.py: self.assertRaises(LockedPage, topic_root.reply, content, 'wikitext')
tests/flow_edit_tests.py: self.assertRaises(LockedPage, topic_reply.reply, content, 'wikitext')
tests/flow_tests.py: self.assertRaises(TypeError, Topic.from_topiclist_data, self.site, '', {})
tests/flow_tests.py: self.assertRaises(TypeError, Topic.from_topiclist_data, board, 521, {})
tests/flow_tests.py: self.assertRaises(TypeError, Topic.from_topiclist_data, board,
tests/flow_tests.py: self.assertRaises(NoPage, Topic.from_topiclist_data, board,
tests/flow_tests.py: self.assertRaises(TypeError, Post.fromJSON, board, 'abc', {})
tests/flow_tests.py: self.assertRaises(TypeError, Post.fromJSON, real_topic, 1234, {})
tests/flow_tests.py: self.assertRaises(TypeError, Post.fromJSON, real_topic, 'abc', [])
tests/flow_tests.py: self.assertRaises(NoPage, Post.fromJSON, fake_topic, 'abc',
tests/flow_tests.py: self.assertRaises(ValueError, Topic.from_topiclist_data,
tests/flow_tests.py: self.assertRaises(ValueError, Topic.from_topiclist_data,
tests/flow_tests.py: self.assertRaises(ValueError, Topic.from_topiclist_data, board,
tests/flow_tests.py: self.assertRaises(AssertionError, Topic.from_topiclist_data, board,
tests/flow_tests.py: self.assertRaises(ValueError, Post.fromJSON, real_topic, 'abc', {})
tests/flow_tests.py: self.assertRaises(ValueError, Post.fromJSON, real_topic, 'abc',
tests/flow_tests.py: self.assertRaises(ValueError, Post.fromJSON, real_topic, 'abc',
tests/flow_tests.py: self.assertRaises(AssertionError, Post.fromJSON, real_topic, 'abc',
tests/http_tests.py: self.assertRaises(pywikibot.FatalServerError,
tests/http_tests.py: self.assertRaises(pywikibot.FatalServerError,
tests/http_tests.py: self.assertRaises(pywikibot.Server504Error,
tests/http_tests.py: self.assertRaises(requests.exceptions.ConnectionError,
tests/http_tests.py: self.assertRaises(requests.exceptions.InvalidSchema,
tests/http_tests.py: self.assertRaises(UnicodeDecodeError, lambda: req.encoding)
tests/http_tests.py: self.assertRaises(UnicodeDecodeError, lambda: req.content)
tests/i18n_tests.py: self.assertRaises(i18n.TranslationError, i18n.twtranslate,
tests/i18n_tests.py: self.assertRaises(i18n.TranslationError,
tests/i18n_tests.py: with self.assertRaises(IndexError):
tests/interwikidata_tests.py: self.assertRaises(ValueError, DummyBot, generator=[wt_page], site=self.wt)
tests/interwikidata_tests.py: self.assertRaises(ValueError, interwikidata.main,
tests/isbn_tests.py: self.assertRaises(AnyIsbnValidationException,
tests/isbn_tests.py: self.assertRaises(AnyIsbnValidationException,
tests/isbn_tests.py: self.assertRaises(AnyIsbnValidationException,
tests/isbn_tests.py: self.assertRaises(AnyIsbnValidationException,
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN10, '0975229LOL') # Invalid characters
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN10, '0975229801') # Invalid checksum
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN10, '09752298') # Invalid length
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN10, '09752X9801') # X in the middle
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN13, '9783161484LOL') # Invalid chars
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN13, '9783161484105') # Invalid checksum
tests/isbn_tests.py: self.assertRaises(IsbnExc, ISBN13, '9783161484') # Invalid length
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link(':', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('__ __', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link(' __ ', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A [ B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A ] B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A { B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A } B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A < B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A > B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A%2523B', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Talk:File:Example.svg', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('.', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('..', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('./Sandbox', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('../Sandbox', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Foo/./Sandbox', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Foo/../Sandbox', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Sandbox/.', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Sandbox/..', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A ~~~ Name', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A ~~~~ Signature', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('A ~~~~~ Timestamp', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('x' * 256, self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Invalid:' + 'X' * 248, self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Talk:', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Category: ', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(InvalidTitle, Link('Category: #bar', self.get_site()).parse)
tests/link_tests.py: self.assertRaises(UnicodeError, Link, title, self.site)
tests/logentry_tests.py: self.assertRaises(KeyError, logentry.page)
tests/logentry_tests.py: with self.assertRaises(pywikibot.NoMoveTarget):
tests/logentry_tests.py: with self.assertRaises(pywikibot.NoMoveTarget):
tests/logentry_tests.py: self.assertRaises(KeyError, logentry.title)
tests/logentry_tests.py: with self.assertRaises(pywikibot.NoPage):
tests/logentry_tests.py: with self.assertRaises(pywikibot.NoPage):
tests/login_tests.py: self.assertRaises(NoUsername, LoginManager)
tests/mediawikiversion_tests.py: self.assertRaises(ValueError, MediaWikiVersion, 'invalid')
tests/mediawikiversion_tests.py: self.assertRaises(ValueError, MediaWikiVersion, '1number')
tests/mediawikiversion_tests.py: self.assertRaises(ValueError, MediaWikiVersion, '1.missing')
tests/mediawikiversion_tests.py: self.assertRaises(AssertionError, MediaWikiVersion, '1.23wmf-1')
tests/mediawikiversion_tests.py: self.assertRaises(ValueError, MediaWikiVersion.from_generator,
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, [True])
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, [False])
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, [None])
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, True)
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, False)
tests/namespace_tests.py: self.assertRaises(TypeError, Namespace.resolve, None)
tests/namespace_tests.py: self.assertRaises(KeyError, Namespace.resolve, -10)
tests/namespace_tests.py: self.assertRaises(KeyError, Namespace.resolve, '-10')
tests/namespace_tests.py: self.assertRaises(KeyError, Namespace.resolve, 'foo')
tests/namespace_tests.py: self.assertRaises(KeyError, Namespace.resolve, ['foo'])
tests/namespace_tests.py: self.assertRaises(KeyError, namespaces.__getitem__, lower)
tests/namespace_tests.py: self.assertRaises(KeyError, namespaces.__getitem__, higher)
tests/namespace_tests.py: self.assertRaises(KeyError, namespaces.__getitem__, 'FOO')
tests/namespace_tests.py: self.assertRaises(KeyError, namespaces.__getitem__, '|')
tests/page_tests.py: self.assertRaises(pywikibot.Error, l3.ns_title, onsite=self.itws)
tests/page_tests.py: self.assertRaises(InvalidTitle, page.title)
tests/page_tests.py: self.assertRaises(InvalidTitle, page.title)
tests/page_tests.py: self.assertRaises(ValueError, pywikibot.page.BasePage, site, title=None)
tests/page_tests.py: self.assertRaises(ValueError, pywikibot.Page, site)
tests/page_tests.py: self.assertRaises(ValueError, pywikibot.Page, site, '')
tests/page_tests.py: self.assertRaises(pywikibot.Error, pywikibot.Page, 'dummy')
tests/page_tests.py: self.assertRaises(pywikibot.NoPage, badpage.get)
tests/page_tests.py: self.assertRaises(pywikibot.exceptions.IsRedirectPage, p2.get)
tests/page_tests.py: self.assertRaises(pywikibot.exceptions.NoPage, p3.get)
tests/page_tests.py: self.assertRaises(pywikibot.exceptions.IsNotRedirectPage,
tests/page_tests.py: self.assertRaises(pywikibot.exceptions.NoPage, p3.set_redirect_target,
tests/page_tests.py: self.assertRaises(pywikibot.NoPage, p.get, force=True)
tests/page_tests.py: self.assertRaises(ValueError, p.markDeletedRevision, 123)
tests/pagegenerators_tests.py: self.assertRaises(calendar.IllegalMonthError, self._run_test, 0)
tests/pagegenerators_tests.py: self.assertRaises(calendar.IllegalMonthError, self._run_test, 12, 13)
tests/pagegenerators_tests.py: self.assertRaises(UnknownExtension, gf.handleArg, '-ql:2')
tests/pagegenerators_tests.py: self.assertRaises(
tests/pagegenerators_tests.py: self.assertRaises(ValueError, gf.handleArg, '-recentchanges:3,2,1')
tests/pagegenerators_tests.py: self.assertRaises(ValueError, gf.handleArg, '-recentchanges:12,-12')
tests/pagegenerators_tests.py: self.assertRaises(
tests/pagegenerators_tests.py: self.assertRaises(
tests/pagegenerators_tests.py: self.assertRaises(NotImplementedError,
tests/pagegenerators_tests.py: self.assertRaises(NotImplementedError, gf.handleArg, '-anotherlog')
tests/pagegenerators_tests.py: with self.assertRaises(ValueError):
tests/proofreadpage_tests.py: self.assertRaises(pywikibot.UnknownExtension,
tests/proofreadpage_tests.py: self.assertRaises(ValueError, ProofreadPage, source)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, ProofreadPage, source)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, ProofreadPage, source)
tests/proofreadpage_tests.py: self.assertRaises(pywikibot.UnknownExtension,
tests/proofreadpage_tests.py: self.assertRaises(ValueError, IndexPage, source)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, IndexPage, source)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, IndexPage, source)
tests/proofreadpage_tests.py: self.assertRaises(KeyError, index_page.get_label_from_page_number, -1)
tests/proofreadpage_tests.py: self.assertRaises(KeyError, index_page.get_label_from_page, None)
tests/proofreadpage_tests.py: self.assertRaises(KeyError, index_page.get_page_number_from_label,
tests/proofreadpage_tests.py: self.assertRaises(KeyError, index_page.get_page_from_label, 'dummy label')
tests/proofreadpage_tests.py: self.assertRaises(ValueError, index_page.page_gen, -1, 2)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, index_page.page_gen, 1, -1)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, index_page.page_gen, 2, 1)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, self.index.page_gen, -1, 2)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, self.index.page_gen, 1, -1)
tests/proofreadpage_tests.py: self.assertRaises(ValueError, self.index.page_gen, 2, 1)
tests/site_detect_tests.py: self.assertRaises((AttributeError, ConnectionError, RuntimeError,
tests/site_tests.py: self.assertRaises(KeyError, mysite.mediawiki_message, "nosuchmessage")
tests/site_tests.py: self.assertRaises(KeyError, self.site.mediawiki_messages, 'about')
tests/site_tests.py: self.assertRaises(KeyError, mysite.mediawiki_messages, msg)
tests/site_tests.py: self.assertRaises(pywikibot.IsNotRedirectPage,
tests/site_tests.py: self.assertRaises(pywikibot.Error, next, errgen)
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.blocks, total=5,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.blocks,
tests/site_tests.py: self.assertRaises(pywikibot.site.PageInUse, site.lock_page, page=p1, block=False)
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.logevents,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.logevents,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.recentchanges,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.recentchanges,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.usercontribs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.usercontribs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.watchlist_revs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.watchlist_revs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.deletedrevs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, mysite.deletedrevs,
tests/site_tests.py: self.assertRaises(pywikibot.Error, site.protect,
tests/site_tests.py: self.assertRaises(pywikibot.Error, site.protect,
tests/site_tests.py: self.assertRaises(pywikibot.NoPage, p.get, force=True)
tests/site_tests.py: self.assertRaises(pywikibot.Error, lambda x: list(x), mysite.patrol())
tests/site_tests.py: self.assertRaises(pywikibot.Error, lambda t: self.mysite.tokens[t], "invalidtype")
tests/site_tests.py: self.assertRaises(KeyError, mysite.siteinfo.__getitem__, not_exists)
tests/site_tests.py: self.assertRaises(pywikibot.Error, self.mysite.loadrevisions,
tests/site_tests.py: self.assertRaises(ValueError, self.mysite.loadrevisions,
tests/site_tests.py: self.assertRaises(ValueError, self.mysite.loadrevisions,
tests/site_tests.py: self.assertRaises(ValueError, self.mysite.loadrevisions,
tests/site_tests.py: self.assertRaises(ValueError, self.mysite.loadrevisions,
tests/site_tests.py: self.assertRaises(ValueError, datasite.search_entities, 'abc',
tests/site_tests.py: self.assertRaises(KeyError, site.hostname)
tests/site_tests.py: self.assertRaises(KeyError, site.hostname)
tests/site_tests.py: self.assertRaises(pywikibot.UnknownSite, pywikibot.Site,
tests/site_tests.py: self.assertRaises(pywikibot.UnknownSite, pywikibot.Site,
tests/site_tests.py: self.assertRaises(KeyError, site.family.hostname, 'en')
tests/site_tests.py: self.assertRaises(pywikibot.UnknownSite,
tests/site_tests.py: with self.assertRaises(NotImplementedError):
tests/site_tests.py: self.assertRaises(pywikibot.UnknownExtension, site._cache_proofreadinfo)
tests/site_tests.py: self.assertRaises(pywikibot.UnknownExtension, lambda x: x.proofread_index_ns, site)
tests/site_tests.py: self.assertRaises(pywikibot.UnknownExtension, lambda x: x.proofread_page_ns, site)
tests/site_tests.py: self.assertRaises(pywikibot.UnknownExtension, lambda x: x.proofread_levels, site)
tests/textlib_tests.py: self.assertRaises(pywikibot.InvalidTitle, textlib.getCategoryLinks,
tests/tools_formatter_tests.py: self.assertRaises(ValueError,
tests/tools_formatter_tests.py: self.assertRaises(TypeError, formatter.color_format, b'{0}', 'a')
tests/tools_formatter_tests.py: self.assertRaises(TypeError, formatter.color_format, b'{black}{0}', 'a')
tests/tools_tests.py: with self.assertRaises(ZeroDivisionError):
tests/tools_tests.py: self.assertRaises(ImportError, self._get_content, self.base_file + '.bz2')
tests/tools_tests.py: self.assertRaises(OSError, self._get_content, self.base_file + '_invalid.7z',
tests/tools_tests.py: self.assertRaises(ValueError, tools.open_archive,
tests/tools_tests.py: self.assertRaises(ValueError, tools.open_archive,
tests/tools_tests.py: self.assertRaises(ValueError, tools.open_archive,
tests/tools_tests.py: self.assertRaises(ValueError, tools.open_archive,
tests/tools_tests.py: self.assertRaises(NotImplementedError, tools.open_archive,
tests/tools_tests.py: self.assertRaises(TypeError, tools.islice_with_ellipsis(self.it, 1, t=''))
tests/tools_tests.py: self.assertRaises(StopIteration, next, deduper)
tests/tools_tests.py: self.assertRaises(StopIteration, next, deduper)
tests/tools_tests.py: self.assertRaises(StopIteration, next, deduper)
tests/tools_tests.py: self.assertRaises(StopIteration, next, gen2)
tests/tools_tests.py: self.assertRaises(StopIteration, next, deduper)
tests/tools_tests.py: self.assertRaises(StopIteration, next, deduper)
tests/ui_options_tests.py: with self.assertRaises(NotImplementedError):
tests/ui_options_tests.py: self.assertRaises(AttributeError, option.test, 1)
tests/ui_options_tests.py: self.assertRaises(ValueError, bot.ListOption, [])
tests/ui_options_tests.py: self.assertRaises(ValueError, option.format, None)
tests/ui_options_tests.py: self.assertRaises(ValueError, option.format)
tests/utils.py: self.cm = self.test_case.assertRaises(APIError, msg=self.msg)
tests/wikibase_tests.py: self.assertRaises(ValueError, claim.setTarget, value="test")
tests/wikibase_tests.py: with self.assertRaises(ValueError):
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbTime, site=repo, precision=15)
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbTime, site=repo, precision='invalid_precision')
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbQuantity, amount=None,
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbMonolingualText,
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbMonolingualText,
tests/wikibase_tests.py: self.assertRaises(ValueError, pywikibot.WbMonolingualText,
tests/wikibase_tests.py: self.assertRaises(pywikibot.InvalidTitle,
tests/wikibase_tests.py: self.assertRaises(pywikibot.NoPage, item.get)
tests/wikibase_tests.py: self.assertRaises(pywikibot.NoPage, item.get)
tests/wikibase_tests.py: self.assertRaises(pywikibot.NoPage, item.get)
tests/wikibase_tests.py: self.assertRaises(pywikibot.InvalidTitle, ItemPage.fromPage, page)
tests/wikibase_tests.py: self.assertRaises(pywikibot.NoPage, getattr(item, method))
tests/wikibase_tests.py: self.assertRaises(pywikibot.NoPage,
tests/wikibase_tests.py: self.assertRaises(pywikibot.IsNotRedirectPage, item.getRedirectTarget)
tests/wikibase_tests.py: self.assertRaises(pywikibot.IsRedirectPage, item.get)
tests/wikibase_tests.py: self.assertRaises(pywikibot.InvalidTitle, PropertyPage, wikidata)
tests/wikibase_tests.py: self.assertRaises(ValueError, date_claim.setTarget, 'foo')
tests/wikibase_tests.py: self.assertRaises(ValueError, url_claim.setTarget, pywikibot.WbTime(2001, site=wikidata))
tests/wikibase_tests.py: self.assertRaises(ValueError, mono_claim.setTarget, 'foo')
tests/wikibase_tests.py: self.assertRaises(NotImplementedError,
tests/wikibase_tests.py: self.assertRaises(NotImplementedError,
tests/wikibase_tests.py: self.assertRaises(NotImplementedError,
tests/wikibase_tests.py: self.assertRaises(NotImplementedError,
tests/wikibase_tests.py: self.assertRaises(NotImplementedError, item.get, sysop=True)
tests/wikibase_tests.py: self.assertRaises(NotImplementedError, pp.get, sysop=True)
tests/wikibase_tests.py: self.assertRaises(AttributeError, page.namespace)
tests/wikibase_tests.py: self.assertRaises(AttributeError, page.namespace)
tests/wikibase_tests.py: self.assertRaises(ValueError, WikibasePage, wikidata,
tests/wikibase_tests.py: self.assertRaises(ValueError, WikibasePage, wikidata,
tests/wikibase_tests.py: self.assertRaises(ValueError, WikibasePage, wikidata,
tests/wikibase_tests.py: self.assertRaises(ValueError, ItemPage, wikidata, 'File:Q1')
tests/wikibase_tests.py: self.assertRaises(ValueError, PropertyPage, wikidata, 'File:P60')
tests/wikibase_tests.py: self.assertRaises(pywikibot.InvalidTitle, ItemPage,
tests/wikibase_tests.py: self.assertRaises(pywikibot.WikiBaseError,
tests/wikidataquery_tests.py: self.assertRaises(TypeError, lambda: query.StringClaim(99, 2))
tests/wikidataquery_tests.py: self.assertRaises(TypeError, lambda: query.Tree(99, "hello"))
tests/wikidataquery_tests.py: self.assertRaises(TypeError, lambda: query.Link(99))
tests/wikidataquery_tests.py: self.assertRaises(TypeError, lambda: query.Link([99]))
tests/wikidataquery_tests.py: self.assertRaises(TypeError, lambda: query.Tree(PropertyPage(self.repo, "P92"),
```