Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Define HAS_AUTHLIB once in tests
Browse files Browse the repository at this point in the history
sick of copypasting
  • Loading branch information
David Robertson committed Nov 21, 2023
1 parent 962e179 commit 9f7a844
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 39 deletions.
10 changes: 1 addition & 9 deletions tests/config/test_oauth_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@

from tests.server import get_clock, setup_test_homeserver
from tests.unittest import TestCase, skip_unless
from tests.utils import default_config

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False

from tests.utils import HAS_AUTHLIB, default_config

# These are a few constants that are used as config parameters in the tests.
SERVER_NAME = "test"
Expand Down
10 changes: 1 addition & 9 deletions tests/handlers/test_oauth_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@

from tests.test_utils import FakeResponse, get_awaitable_result
from tests.unittest import HomeserverTestCase, skip_unless
from tests.utils import mock_getRawHeaders

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False

from tests.utils import HAS_AUTHLIB, mock_getRawHeaders

# These are a few constants that are used as config parameters in the tests.
SERVER_NAME = "test"
Expand Down
8 changes: 1 addition & 7 deletions tests/rest/admin/test_jwks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
from synapse.rest.synapse.client import build_synapse_client_resource_tree

from tests.unittest import HomeserverTestCase, override_config, skip_unless

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False
from tests.utils import HAS_AUTHLIB


@skip_unless(HAS_AUTHLIB, "requires authlib")
Expand Down
8 changes: 1 addition & 7 deletions tests/rest/client/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@
from tests import unittest
from tests.http.server._base import make_request_with_cancellation_test
from tests.unittest import override_config

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False
from tests.utils import HAS_AUTHLIB


class KeyQueryTestCase(unittest.HomeserverTestCase):
Expand Down
8 changes: 1 addition & 7 deletions tests/rest/test_well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
from synapse.rest.well_known import well_known_resource

from tests import unittest

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False
from tests.utils import HAS_AUTHLIB


class WellKnownTests(unittest.HomeserverTestCase):
Expand Down
7 changes: 7 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
from synapse.storage.engines import create_engine
from synapse.storage.prepare_database import prepare_database

try:
import authlib # noqa: F401

HAS_AUTHLIB = True
except ImportError:
HAS_AUTHLIB = False

# set this to True to run the tests against postgres instead of sqlite.
#
# When running under postgres, we first create a base database with the name
Expand Down

0 comments on commit 9f7a844

Please sign in to comment.