From 98f19564c2a9feb108845d33bf3631fa219e51c6 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Wed, 24 Aug 2022 08:20:28 -0700 Subject: [PATCH 1/2] chore: fix issue if only run test_gitlab.py func test Make it so can run just the test_gitlab.py functional test. For example: $ tox -e api_func_v4 -- -k test_gitlab.py --- tests/functional/api/test_gitlab.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py index 08f9d9a4c..8e6221050 100644 --- a/tests/functional/api/test_gitlab.py +++ b/tests/functional/api/test_gitlab.py @@ -126,6 +126,7 @@ def test_hooks(gl): def test_namespaces(gl, get_all_kwargs): + gl.auth() current_user = gl.user.username namespaces = gl.namespaces.list(**get_all_kwargs) From bd4dfb4729377bf64c552ef6052095aa0b5658b8 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Wed, 24 Aug 2022 14:31:40 -0700 Subject: [PATCH 2/2] chore: Only check for our UserWarning The GitHub CI is showing a ResourceWarning, causing our test to fail. Update test to only look for our UserWarning which should not appear. What was seen when debugging the GitHub CI: {message: ResourceWarning( "unclosed " ), category: 'ResourceWarning', filename: '/home/runner/work/python-gitlab/python-gitlab/.tox/api_func_v4/lib/python3.10/site-packages/urllib3/poolmanager.py', lineno: 271, line: None } --- tests/functional/api/test_gitlab.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py index 8e6221050..f2bdf5099 100644 --- a/tests/functional/api/test_gitlab.py +++ b/tests/functional/api/test_gitlab.py @@ -240,7 +240,11 @@ def test_list_all_false_nowarning(gl, recwarn): def test_list_all_true_nowarning(gl, get_all_kwargs, recwarn): """Using `get_all=True` will disable the warning""" items = gl.gitlabciymls.list(**get_all_kwargs) - assert not recwarn + for warn in recwarn: + if issubclass(warn.category, UserWarning): + # Our warning has a link to the docs in it, make sure we don't have + # that. + assert "python-gitlab.readthedocs.io" not in str(warn.message) assert len(items) > 20