jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1027554?usp=email )
Change subject: [tests] update coverage for version.py ......................................................................
[tests] update coverage for version.py
Change-Id: Ie1dcfb1e0731428505e4ce67e63038b380fdaa00 --- M pywikibot/version.py M tests/version_tests.py 2 files changed, 7 insertions(+), 7 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py index 0e3f35a..722a377 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -103,7 +103,7 @@ exceptions[vcs_func] = vcs_func.__name__, e else: break - else: + else: # pragma: no cover # nothing worked; version unknown (but suppress exceptions) # the value is most likely '$Id' + '$', it means that # pywikibot was imported without using version control at all. @@ -114,14 +114,14 @@ exceptions = None
# Git and SVN can silently fail, as it may be a nightly. - if exceptions: + if exceptions: # pragma: no cover pywikibot.debug(f'version algorithm exceptions:\n{exceptions!r}')
if isinstance(date, str): datestring = date elif isinstance(date, time.struct_time): datestring = time.strftime('%Y/%m/%d, %H:%M:%S', date) - else: + else: # pragma: no cover warn('Unable to detect package date', UserWarning) datestring = '-2 (unknown)'
@@ -258,7 +258,7 @@ """ file = Path(path or _get_program_dir()) if not path: - file /= 'pywikibot' + file /= 'pywikibot' # pragma: no cover file /= 'version'
with file.open() as data: @@ -267,7 +267,7 @@ date = time.strptime(date[:19], '%Y-%m-%dT%H:%M:%S')
if not date or not tag or not rev: - raise VersionParseError + raise VersionParseError # pragma: no cover return (tag, rev, date, hsh)
@@ -299,7 +299,7 @@ headers={'user-agent': '{pwb}'}).text[4:] try: return json.loads(buf)['revision'] - except Exception as e: + except Exception as e: # pragma: no cover raise VersionParseError(f'{e!r} while parsing {buf!r}')
diff --git a/tests/version_tests.py b/tests/version_tests.py index 217bbd2..96a6de1 100644 --- a/tests/version_tests.py +++ b/tests/version_tests.py @@ -58,7 +58,7 @@ hsh = version.getversion_onlinerepo('branches/' + branch) try: int(hsh, 16) - except ValueError: + except ValueError: # pragma: no cover self.fail( f'{hsh!r} is not a valid hash of {branch} branch')