<a id="testing-python-social-auth"></a>

# Testing python-social-auth

The instructions below apply to `social-auth-core`. Framework integrations
have their own test suites and dependency requirements; follow the contributing
instructions in the integration’s repository when changing framework behavior.
See [Development setup](development.html.md) for working with local checkouts.

The core test suite uses [pytest](https://docs.pytest.org/) and [responses](https://github.com/getsentry/responses) to mock provider HTTP responses.
Tests do not require live provider accounts, application keys, or secrets. Keep
provider traffic mocked when adding regression tests.

<a id="installing-dependencies"></a>

## Installing dependencies

From the root of the `social-core` checkout, install [uv](https://docs.astral.sh/uv/getting-started/installation/) and synchronize the
development dependencies and all optional backend dependencies:

```default
uv sync --all-extras --dev
```

The SAML dependencies require system libraries, including libxml2 and xmlsec
development packages when building their Python bindings. The core’s
[test workflow](https://github.com/python-social-auth/social-core/blob/master/.github/workflows/test.yml) records the system setup used in CI.

<a id="running-tests"></a>

## Running tests

Run the core suite from the checkout root:

```default
uv run pytest
```

During development, start with the test module relevant to the change, for
example:

```default
uv run pytest social_core/tests/backends/test_github.py
```

Add regression tests for changed behavior. Changes shared by several providers
should cover the common protocol implementation and representative backends.
Changes to framework integration contracts also need tests in the affected
integration repository.

<a id="tox"></a>

## Tox

Use [tox](https://tox.wiki/) to test compatibility across the environments configured in the core’s
`tox.ini`:

```default
uvx tox
```

To select one Python environment, for example Python 3.14:

```default
uvx tox -e py314
```

The selected Python interpreters must be available. Consult `tox.ini` for the
current environment list.

<a id="linting"></a>

## Linting

Run the repository’s configured formatting and linting hooks before submitting
changes:

```default
uvx prek run --all-files
```
