diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3608b8..730bdb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: python-version: '3.10' - name: Install dependencies run: | - python -m pip install -U pip + python -m pip install --upgrade pip python -m pip install flake8 - name: Check run: python -m flake8 @@ -38,10 +38,10 @@ jobs: - name: Set Up Python uses: actions/setup-python@v7.0.0 with: - python-version: '3.13' + python-version: '3.x' - name: Install dependencies run: | - python -m pip install -U pip + python -m pip install --upgrade pip python -m pip install mypy .[all] - name: Check run: python -m mypy --install-types --non-interactive @@ -55,6 +55,7 @@ jobs: strategy: fail-fast: false matrix: + httpx: [ 'httpx', 'httpx2' ] python: - '3.9' - '3.10' @@ -76,10 +77,12 @@ jobs: python-version: ${{ matrix.python }} - name: Install dependencies run: | - python -m pip install -U pip - python -m pip install -U setuptools wheel - python -m pip install -U .[all] pytest-cov codecov + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools wheel + python -m pip install --upgrade .[all] pytest-cov codecov - name: Run Tests + env: + HTTPX: ${{ matrix.httpx }} run: python -m pytest --cov=httpx_gssapi --cov-report=xml - name: Upload Coverage run: python -m codecov --token=${{ secrets.CODECOV_TOKEN }} @@ -97,11 +100,11 @@ jobs: - name: Set Up Python uses: actions/setup-python@v7.0.0 with: - python-version: '3.10' + python-version: '3.x' - name: Install dependencies run: | - python -m pip install -U pip - python -m pip install -U setuptools wheel + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools wheel - name: Build run: python setup.py sdist bdist_wheel - name: Change Log diff --git a/httpx_gssapi/__init__.py b/httpx_gssapi/__init__.py index 3c53224..36a3da5 100644 --- a/httpx_gssapi/__init__.py +++ b/httpx_gssapi/__init__.py @@ -7,7 +7,7 @@ of requests_gssapi to HTTPX and adds optional GSSAPI authentication support and supports mutual authentication. Basic GET usage: - >>> import httpx + >>> import httpx # or `import httpx2` >>> from httpx_gssapi import HTTPSPNEGOAuth >>> r = httpx.get("http://example.org", auth=HTTPSPNEGOAuth()) diff --git a/httpx_gssapi/exceptions.py b/httpx_gssapi/exceptions.py index 86a6868..daaf36d 100644 --- a/httpx_gssapi/exceptions.py +++ b/httpx_gssapi/exceptions.py @@ -6,9 +6,13 @@ """ +from os import getenv from typing import Optional -from httpx import RequestError, Request, Response +if getenv("HTTPX") == "httpx2": + from httpx2 import RequestError, Request, Response +else: + from httpx import RequestError, Request, Response # type: ignore[assignment] class MutualAuthenticationError(RequestError): diff --git a/httpx_gssapi/gssapi_.py b/httpx_gssapi/gssapi_.py index 0f5a99b..a9e70a3 100644 --- a/httpx_gssapi/gssapi_.py +++ b/httpx_gssapi/gssapi_.py @@ -2,6 +2,7 @@ import logging from itertools import chain from functools import wraps +from os import getenv from typing import Generator, Optional, List, Any, Union from base64 import b64encode, b64decode @@ -10,8 +11,12 @@ from gssapi import SecurityContext from gssapi.exceptions import GSSError -import httpx -from httpx import Auth, Request, Response +if getenv("HTTPX") == "httpx2": + import httpx2 as httpx + from httpx2 import Auth, Request, Response +else: + import httpx # type: ignore[no-redef] + from httpx import Auth, Request, Response # type: ignore[assignment] from .exceptions import MutualAuthenticationError, SPNEGOExchangeError diff --git a/setup.cfg b/setup.cfg index fb45282..353f945 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,7 @@ python_requires = >=3.9 packages = httpx_gssapi install_requires = httpx>=0.16,<0.29 + httpx2 gssapi [options.extras_require] @@ -83,7 +84,7 @@ packages = tests [tox:tox] -envlist = py36, py37, py38, py39, py310 +envlist = py39, py310, py311, py312, py313, py314, py315 [testenv] deps = diff --git a/tests/test_end_to_end.py b/tests/test_end_to_end.py index 4c1cc48..c70cd24 100644 --- a/tests/test_end_to_end.py +++ b/tests/test_end_to_end.py @@ -1,7 +1,13 @@ #!/usr/bin/env python """Tests for httpx_gssapi.""" + +from os import getenv + +if getenv("HTTPX") == "httpx2": + import httpx2 as httpx +else: + import httpx # type: ignore[no-redef] import gssapi -import httpx import k5test # type: ignore[import-untyped] import pytest diff --git a/tests/test_mocked.py b/tests/test_mocked.py index 770bfc3..7bc0508 100644 --- a/tests/test_mocked.py +++ b/tests/test_mocked.py @@ -3,11 +3,15 @@ import logging from base64 import b64encode +from os import getenv from unittest.mock import Mock, patch import pytest -import httpx +if getenv("HTTPX") == "httpx2": + import httpx2 as httpx +else: + import httpx # type: ignore[no-redef] import gssapi import gssapi.exceptions