jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/835642 )
Change subject: [cleanup] remove userinterfaces.gui.ListBoxWindow
......................................................................
[cleanup] remove userinterfaces.gui.ListBoxWindow
remove ListBoxWindow which was introduced in compat 2004 but was neither
used anywhere in the framework nor is it documented how to use it.
After creating the listbox window the only choices is to close the window
by clicking ok. There is no method tho get an element of the numbered list.
Change-Id: Ief1a3172bdacbb4c45a66d834ce31247d3a64a82
---
M pywikibot/userinterfaces/gui.py
1 file changed, 0 insertions(+), 54 deletions(-)
Approvals:
JJMC89: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py
index 1e29c12..0f37515 100644
--- a/pywikibot/userinterfaces/gui.py
+++ b/pywikibot/userinterfaces/gui.py
@@ -429,60 +429,6 @@
return 'break'
-# the following class isn't used anywhere in the framework: ####
-class ListBoxWindow:
-
- """List box window."""
-
- # called when user pushes the OK button.
- # closes the window.
- def pressedOK(self) -> None:
- """
- Perform OK operation.
-
- Closes listbox.
- """
- self.parent.destroy()
-
- def __init__(self, parent=None) -> None:
- """Initializer."""
- if parent is None:
- # create a new window
- parent = tkinter.Tk()
- self.parent = parent
-
- # selectable: only one item
- self.listbox = tkinter.Listbox(parent, selectmode=tkinter.SINGLE)
- # put list into main frame, using all available space
- self.listbox.pack(anchor=tkinter.CENTER, fill=tkinter.BOTH)
-
- # lower subframe which will contain one button
- self.bottom_frame = tkinter.Frame(parent)
- self.bottom_frame.pack(side=tkinter.BOTTOM)
-
- buttonOK = tkinter.Button(self.bottom_frame, text='OK',
- command=self.pressedOK)
- buttonOK.pack(side=tkinter.LEFT, fill=tkinter.X)
- # idea: set title to cur_disambiguation
-
- def list(self, list):
- """Put list of alternatives into listbox."""
- self.list = list
- # find required area
- laenge = len(list)
- maxbreite = 0
- for i in range(laenge):
- # cycle through all listitems to find maxlength
- if len(list[i]) + len(str(i)) > maxbreite:
- maxbreite = len(list[i]) + len(str(i))
- # show list as formerly in DOS-window
- self.listbox.insert(tkinter.END, str(i) + ' - ' + list[i])
- # set optimized height & width
- self.listbox.config(height=laenge, width=maxbreite + 2)
- # wait for user to push a button which will destroy (close) the window
- return self.list
-
-
class Tkdialog:
"""The dialog window for image info."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/835642
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ief1a3172bdacbb4c45a66d834ce31247d3a64a82
Gerrit-Change-Number: 835642
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/837671 )
Change subject: [tests] Remove some code parts from coverage
......................................................................
[tests] Remove some code parts from coverage
Also improve some tests.
Change-Id: I6bb8a2b346e9dc282c59d4776a0d51b0684f6e33
---
M make_dist.py
M pwb.py
M tests/bot_tests.py
M tests/cosmetic_changes_tests.py
M tests/i18n_tests.py
M tests/pagegenerators_tests.py
M tests/siteinfo_tests.py
M tests/textlib_tests.py
M tests/timestripper_tests.py
M tests/ui_tests.py
M tests/wikibase_tests.py
11 files changed, 41 insertions(+), 37 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/make_dist.py b/make_dist.py
index 116e656..cb5c11a 100644
--- a/make_dist.py
+++ b/make_dist.py
@@ -112,7 +112,7 @@
:return: Return whether dist is to be installed locally or to be
uploaded
"""
- if '-help' in sys.argv:
+ if '-help' in sys.argv: # pragma: no cover
info(__doc__)
info(setup.__doc__)
sys.exit()
diff --git a/pwb.py b/pwb.py
index 4bf8253..b1694de 100755
--- a/pwb.py
+++ b/pwb.py
@@ -79,12 +79,12 @@
'misconfigured.\n'.format(wikibot_version, scripts_version))
# calculate previous minor release
- if wikibot_version.minor > 0:
+ if wikibot_version.minor > 0: # pragma: no cover
prev_wikibot = Version('{v.major}.{}.{v.micro}'
.format(wikibot_version.minor - 1,
v=wikibot_version))
- if scripts_version.release < prev_wikibot.release: # pragma: no cover
+ if scripts_version.release < prev_wikibot.release:
print('WARNING: Scripts package version {} is behind legacy '
'Pywikibot version {} and current version {}\nYour scripts '
'may need an update or be misconfigured.\n'
@@ -138,7 +138,7 @@
# set environment values
old_env = os.environ.copy()
- for key, value in environ:
+ for key, value in environ: # pragma: no cover
os.environ[key] = value
sys.argv = [filename] + args
@@ -162,7 +162,7 @@
# end of snippet from coverage
# Restore environment values
- for key, value in environ:
+ for key, value in environ: # pragma: no cover
if key in old_env:
os.environ[key] = old_env[key]
else:
diff --git a/tests/bot_tests.py b/tests/bot_tests.py
index 8b51092..0d11ca5 100755
--- a/tests/bot_tests.py
+++ b/tests/bot_tests.py
@@ -93,7 +93,7 @@
# When an AssertionError happened we shouldn't do these
# assertions as they are invalid anyway and hide the actual
# failed assertion
- return
+ return # pragma: no cover
self.assertEqual(self.bot.counter['read'], treated)
self.assertEqual(self.bot.counter['write'], written)
if exception:
diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py
index bd85465..6d38f91 100755
--- a/tests/cosmetic_changes_tests.py
+++ b/tests/cosmetic_changes_tests.py
@@ -395,14 +395,14 @@
'==2<!--\n-->==\nt',
self.cct.removeEmptySections('==1==\n==2<!--\n-->==\nt'))
- def test_translateAndCapitalizeNamespaces(self):
+ def test_translate_and_capitalize_namespaces(self):
"""Test translateAndCapitalizeNamespaces method."""
self.assertEqual(
'[[Wikipedia:Test]], [[Wikipedia:Test]], [[Datei:Test]]',
self.cct.translateAndCapitalizeNamespaces(
'[[Project:Test]], [[wikipedia:Test]], [[Image:Test]]'))
- def test_translateMagicWords(self):
+ def test_translate_magic_words(self):
"""Test translateMagicWords method."""
self.assertEqual(
'[[File:Foo.bar|mini]]',
@@ -471,23 +471,23 @@
self.cct.cleanUpLinks('[[Sand|sand]]box'))
@unittest.expectedFailure
- def test_cleanUpLinks(self):
- """
- Test cleanUpLinks method.
+ def test_cleanup_links(self):
+ """Test cleanUpLinks method.
This method fails for the given samples from library. Either
the method has to be changed or the examples must be fixed.
"""
- self.assertEqual('text [[title]] text',
- self.cct.cleanUpLinks('text[[ title ]]text'))
- self.assertEqual('text [[title|name]] text',
- self.cct.cleanUpLinks('text[[ title | name ]]text'))
- self.assertEqual('text[[title|name]]text',
- self.cct.cleanUpLinks('text[[ title |name]]text'))
- self.assertEqual('text [[title|name]]text',
- self.cct.cleanUpLinks('text[[title| name]]text'))
+ tests = [
+ ('text [[title]] text', 'text[[ title ]]text'),
+ ('text [[title|name]] text', 'text[[ title | name ]]text'),
+ ('text[[title|name]]text', 'text[[ title |name]]text'),
+ ('text [[title|name]]text', 'text[[title| name]]text'),
+ ]
+ for result, text in tests:
+ with self.subTest(text=text):
+ self.assertEqual(self.cct.cleanUpLinks(text), result)
- def test_replaceDeprecatedTemplates(self):
+ def test_replace_deprecated_templates(self):
"""Test replaceDeprecatedTemplates method."""
self.assertEqual('{{Belege fehlen}}',
self.cct.replaceDeprecatedTemplates('{{Belege}}'))
@@ -503,13 +503,13 @@
family = 'wikipedia'
code = 'fa'
- def test_fixArabicLetters_comma(self):
+ def test_fix_arabic_letters_comma(self):
"""Test fixArabicLetters comma replacements."""
self.assertEqual(self.cct.fixArabicLetters(','), '،')
self.assertEqual(self.cct.fixArabicLetters('A,b,ا,۴,'),
'A,b،ا،۴،')
- def test_fixArabicLetters_comma_skip(self):
+ def test_fix_arabic_letters_comma_skip(self):
"""Test fixArabicLetters Latin comma not replaced."""
self.assertEqual(self.cct.fixArabicLetters('a", b'), 'a", b')
self.assertEqual(self.cct.fixArabicLetters('a, "b'), 'a, "b')
@@ -532,7 +532,7 @@
self.assertEqual(self.cct.fixArabicLetters('a", ۴'), 'a", ۴')
self.assertEqual(self.cct.fixArabicLetters(' , '), ' , ')
- def test_fixArabicLetters_letters(self):
+ def test_fix_arabic_letters_letters(self):
"""Test fixArabicLetters letter replacements."""
self.assertEqual(self.cct.fixArabicLetters('ك'),
'ک')
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 9e21ed3..bf81f14 100755
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -238,7 +238,7 @@
"""Verify that the test translations are not empty."""
if not isinstance(cls.message_package, str):
raise TypeError('{}.message_package must be a package name'
- .format(cls.__name__))
+ .format(cls.__name__)) # pragma: no cover
# The call to set_messages_package below exists only to confirm
# that the package exists and messages are available, so
# that tests can be skipped if the i18n data doesn't exist.
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 1545b5f..6c2b890 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -1701,7 +1701,8 @@
with self.assertRaises(ValueError):
for _ in pagegenerators.UnconnectedPageGenerator(self.site,
total=5):
- raise AssertionError("this shouldn't be reached")
+ raise AssertionError(
+ "this shouldn't be reached") # pragma: no cover
class TestLinksearchPageGenerator(TestCase):
diff --git a/tests/siteinfo_tests.py b/tests/siteinfo_tests.py
index 0a3c189..76f6031 100755
--- a/tests/siteinfo_tests.py
+++ b/tests/siteinfo_tests.py
@@ -72,7 +72,7 @@
def test_no_cache(self):
"""Test siteinfo caching can be disabled."""
if 'fileextensions' in self.site.siteinfo._cache:
- del self.site.siteinfo._cache['fileextensions']
+ del self.site.siteinfo._cache['fileextensions'] # pragma: no cover
self.site.siteinfo.get('fileextensions', cache=False)
self.assertFalse(self.site.siteinfo.is_cached('fileextensions'))
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index c92e84d..86c494c 100755
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -895,14 +895,16 @@
# These tests require to get the actual part which is before the title
# (interwiki and namespace prefixes) which could be then compared
# case insensitive.
- self.assertEqual(
- textlib.replace_links('[[Image:Foobar]]',
- ('File:Foobar', 'File:Foo'), self.wp_site),
- '[[File:Foo|Image:Foobar]]')
- self.assertEqual(
- textlib.replace_links('[[en:File:Foobar]]',
- ('File:Foobar', 'File:Foo'), self.wp_site),
- '[[File:Foo|en:File:Foobar]]')
+ tests = [
+ ('[[Image:Foobar]]', '[[File:Foo|Image:Foobar]]'),
+ ('[[en:File:Foobar]]', '[[File:Foo|en:File:Foobar]]'),
+ ]
+ for link, result in tests:
+ with self.subTest(link=link):
+ self.assertEqual(
+ textlib.replace_links(
+ link, ('File:Foobar', 'File:Foo'), self.wp_site),
+ result)
def test_linktrails(self):
"""Test that the linktrails are used or applied."""
diff --git a/tests/timestripper_tests.py b/tests/timestripper_tests.py
index 65bb9a8..73bd011 100755
--- a/tests/timestripper_tests.py
+++ b/tests/timestripper_tests.py
@@ -244,7 +244,7 @@
self.assertEqual(self.ts.timestripper(txt_match), res)
if 'match3' not in self.sites[key]:
- return
+ return # pragma: no cover
txt_match = self.sites[key]['match3']
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index 8fecffe..ff9130b 100755
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -403,7 +403,8 @@
def _encounter_color(self, color, target_stream):
"""Patched encounter_color method."""
- raise AssertionError('This method should not be invoked')
+ raise AssertionError(
+ 'This method should not be invoked') # pragma: no cover
def test_no_color(self):
"""Test a string without any colors."""
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index f9ec66a..8f1f13f 100755
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -42,7 +42,7 @@
for page in gen:
if not page.properties().get('wikibase_item'):
return page
- return None
+ return None # pragma: no cover
class WbRepresentationTestCase(WikidataTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/837671
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6bb8a2b346e9dc282c59d4776a0d51b0684f6e33
Gerrit-Change-Number: 837671
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/837210 )
Change subject: [bugfix]: Popen() does not expects int in args
......................................................................
[bugfix]: Popen() does not expects int in args
Popen() accept as args:
- a str
- a seq of str, bytes or os.PathLike object, not int
Change-Id: I5a6067c9843bb58acf4a40ff925eb4a08c9a2826
---
M pywikibot/tools/djvu.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py
index 3da4eda..02e7c4e 100644
--- a/pywikibot/tools/djvu.py
+++ b/pywikibot/tools/djvu.py
@@ -227,7 +227,7 @@
if not self.has_text(force=force):
raise ValueError('Djvu file {} has no text layer.'
.format(self.file))
- res, stdoutdata = _call_cmd(['djvutxt', f'--page={int(n)}',
+ res, stdoutdata = _call_cmd(['djvutxt', f'--page={n}',
self.file])
if not res:
return False
@@ -258,7 +258,7 @@
return False
# Convert white_page to djvu.
- res, data = _call_cmd(['c44', white_ppm, '-dpi', dpi])
+ res, data = _call_cmd(['c44', white_ppm, '-dpi', str(dpi)])
os.unlink(white_ppm) # rm white_page.ppm before returning.
if not res:
return False
@@ -266,12 +266,12 @@
# Delete page n.
# Get ref page info for later checks.
info_ref_page = self.page_info(ref_page)
- res, data = _call_cmd(['djvm', '-d', self.file, n])
+ res, data = _call_cmd(['djvm', '-d', self.file, str(n)])
if not res:
return False
# Insert new page
- res, data = _call_cmd(['djvm', '-i', self.file, white_djvu, n])
+ res, data = _call_cmd(['djvm', '-i', self.file, white_djvu, str(n)])
os.unlink(white_djvu) # rm white_page.djvu before returning.
if not res:
return False
@@ -300,7 +300,7 @@
# Delete page n.
# Get ref page info for later checks.
info_ref_page = self.page_info(ref_page)
- res, _ = _call_cmd(['djvm', '-d', self.file, n])
+ res, _ = _call_cmd(['djvm', '-d', self.file, str(n)])
if not res:
return False
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/837210
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5a6067c9843bb58acf4a40ff925eb4a08c9a2826
Gerrit-Change-Number: 837210
Gerrit-PatchSet: 2
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged