Skip to content

Commit

Permalink
tests: GithubException now accepts also headers
Browse files Browse the repository at this point in the history
We need to update how we mock GithubException since 1.55 it now accepts
HTTP headers in form of a positional argument as well:

PyGithub/PyGithub#1887

This is implemented with inspect.signature so our tests work for both
versions of pygithub <1.55 and >=1.55 because 1.55 is not in stable
Fedora yet.

Kudos @lbarcziova

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
  • Loading branch information
TomasTomecek committed Apr 28, 2021
1 parent 8660647 commit 3189283
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/unit/test_reporting.py
@@ -1,5 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
from inspect import signature

import github
import gitlab
Expand Down Expand Up @@ -170,7 +171,21 @@ def test_set_status_gitlab(
"We made it!",
"packit/pr-rpm-build",
"https://api.packit.dev/build/111/logs",
(github.GithubException, (None, None), dict()),
(
github.GithubException,
# https://docs.python.org/3/library/inspect.html#inspect.signature
# to account for changes in positional arguments: pygithub 1.55 added headers
# as additional positional argument; this creates an iterable and sets None
# for every argument of GithubException.__init__ except for 'self'
[
None
for param_name, param in signature(
github.GithubException.__init__
).parameters.items()
if param_name != "self"
],
dict(),
),
id="GitHub PR",
),
pytest.param(
Expand Down

0 comments on commit 3189283

Please sign in to comment.