Repository: jazzband/django-axes
Pull request #1285 (2025-03-03 12:17:32)

chore(deps): bump pytest from 8.3.4 to 8.3.5
Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.4 to 8.3.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pytest-dev/pytest/releases">pytest's releases</a>.</em></p>
<blockquote>
<h2>8.3.5</h2>
<h1>pytest 8.3.5 (2025-03-02)</h1>
<h2>Bug fixes</h2>
<ul>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/11777">#11777</a>: Fixed issue where sequences were still being shortened even with <code>-vv</code> verbosity.</li>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/12888">#12888</a>: Fixed broken input when using Python 3.13+ and a <code>libedit</code> build of Python, such as on macOS or with uv-managed Python binaries from the <code>python-build-standalone</code> project. This could manifest e.g. by a broken prompt when using <code>Pdb</code>, or seeing empty inputs with manual usage of <code>input()</code> and suspended capturing.</li>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/13026">#13026</a>: Fixed <code>AttributeError</code>{.interpreted-text role=&quot;class&quot;} crash when using <code>--import-mode=importlib</code> when top-level directory same name as another module of the standard library.</li>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/13053">#13053</a>: Fixed a regression in pytest 8.3.4 where, when using <code>--import-mode=importlib</code>, a directory containing py file with the same name would cause an <code>ImportError</code></li>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/13083">#13083</a>: Fixed issue where pytest could crash if one of the collected directories got removed during collection.</li>
</ul>
<h2>Improved documentation</h2>
<ul>
<li>
<p><a href="https://redirect.github.com/pytest-dev/pytest/issues/12842">#12842</a>: Added dedicated page about using types with pytest.</p>
<p>See <code>types</code>{.interpreted-text role=&quot;ref&quot;} for detailed usage.</p>
</li>
</ul>
<h2>Contributor-facing changes</h2>
<ul>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/13112">#13112</a>: Fixed selftest failures in <code>test_terminal.py</code> with Pygments &gt;= 2.19.0</li>
<li><a href="https://redirect.github.com/pytest-dev/pytest/issues/13256">#13256</a>: Support for Towncrier versions released in 2024 has been re-enabled
when building Sphinx docs -- by <code>webknjaz</code>{.interpreted-text role=&quot;user&quot;}.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pytest-dev/pytest/commit/b55ab2aabb68c0ce94c3903139b062d0c2790152"><code>b55ab2a</code></a> Prepare release version 8.3.5</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/e217726d2a0edfaf58eae95bf835b85834b96da3"><code>e217726</code></a> Added dedicated page about using types with pytest <a href="https://redirect.github.com/pytest-dev/pytest/issues/12842">#12842</a> (<a href="https://redirect.github.com/pytest-dev/pytest/issues/12963">#12963</a>) (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13260">#13260</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/2fa3f8306c3da4aad7f7349a4947ac37ba6c652f"><code>2fa3f83</code></a> Add more resources and studies to flaky tests page in docs (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13250">#13250</a>) (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13259">#13259</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/e5c2efe3c36199731b41fd68bbf4df5e21404a8b"><code>e5c2efe</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/13256">#13256</a> from webknjaz/maintenance/towncrier-bump (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13258">#13258</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/3419674225a3a7b7d6f93650d75f6de52fe637d5"><code>3419674</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/13187">#13187</a> from pytest-dev/patchback/backports/8.3.x/b4009b319...</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/b75cfb162dbb927739698effa3fbcf279655da49"><code>b75cfb1</code></a> Add readline workaround for libedit (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13176">#13176</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/edbfff72a4051ed9c5f3d9b5d6f316b407cb6961"><code>edbfff7</code></a> doc: Clarify capturing .readouterr() return value (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13222">#13222</a>) (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13225">#13225</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/2ebba0063c66b77a7bd171221de059f3b3e47b86"><code>2ebba00</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/13199">#13199</a> from jakkdl/tox_docs_no_fetch (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13200">#13200</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/eb6496b79759f9acde581ed9d7a0777a49b5f820"><code>eb6496b</code></a> doc: Change training to remote only (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13196">#13196</a>) (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13197">#13197</a>)</li>
<li><a href="https://github.com/pytest-dev/pytest/commit/78cf1f67f707fc07372a89775fd10d2065b5f17a"><code>78cf1f6</code></a> ci: Bump build-and-inspect-python-package (<a href="https://redirect.github.com/pytest-dev/pytest/issues/13188">#13188</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest/compare/8.3.4...8.3.5">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest&package-manager=pip&previous-version=8.3.4&new-version=8.3.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

> **Note**
> Automatic rebases have been disabled on this pull request as it has been open for over 30 days.


Patch:
diff --git a/axes/handlers/database.py b/axes/handlers/database.py
index c8e119d..9effa77 100644
--- a/axes/handlers/database.py
+++ b/axes/handlers/database.py
@@ -117,10 +117,10 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
         return attempt_count
 
     def user_login_failed(self, sender, credentials: dict, request=None, **kwargs):
-        """When user login fails, save AccessFailureLog record in database,
+        """
+        When user login fails, save AccessFailureLog record in database,
         save AccessAttempt record in database, mark request with
         lockout attribute and emit lockout signal.
-
         """
 
         log.info("AXES: User login failed, running database handler for failure.")
@@ -261,9 +261,6 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
         When user logs in, update the AccessLog related to the user.
         """
 
-        # 1. database query: Clean up expired user attempts from the database
-        clean_expired_user_attempts(request, credentials)
-
         username = user.get_username()
         credentials = get_credentials(username)
         client_str = get_client_str(
@@ -276,6 +273,9 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
 
         log.info("AXES: Successful login by %s.", client_str)
 
+        # 1. database query: Clean up expired user attempts from the database
+        clean_expired_user_attempts(request, credentials)
+
         if not settings.AXES_DISABLE_ACCESS_LOG:
             # 2. database query: Insert new access logs with login time
             AccessLog.objects.create(
@@ -304,10 +304,8 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
         When user logs out, update the AccessLog related to the user.
         """
 
-        # 1. database query: Clean up expired user attempts from the database
-        clean_expired_user_attempts(request)
-
         username = user.get_username() if user else None
+        credentials = get_credentials(username) if username else None
         client_str = get_client_str(
             username,
             request.axes_ip_address,
@@ -316,6 +314,9 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
             request,
         )
 
+        # 1. database query: Clean up expired user attempts from the database
+        clean_expired_user_attempts(request, credentials)
+
         log.info("AXES: Successful logout by %s.", client_str)
 
         if username and not settings.AXES_DISABLE_ACCESS_LOG:


Test patch:
diff --git a/requirements-test.txt b/requirements-test.txt
index 867c416..bb3f344 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,7 +1,7 @@
 -e .
 django-ipware>=3
 coverage==7.8.0
-pytest==8.3.4
+pytest==8.3.5
 pytest-cov==6.1.1
-pytest-django==4.10.0
+pytest-django==4.11.1
 pytest-subtests==0.14.1