Repository: pypa/sampleproject (language: python)

Issue:
Update tox version? And tox best practices?
The `tox` [docs](https://tox.wiki/en/latest/user_guide.html) use `>=4`

It is safe to update it here? Currently:
```.ini
# Define the minimal tox version required to run;
# if the host tox is less than this the tool with create an environment and
# provision it with a tox that satisfies it under provision_tox_env.
# At least this version is needed for PEP 517/518 support.
minversion = 3.3.0
```

\+ I know this repo isn't intended to show `tox` best practices, but if they've changed (I don't know), they can also be changed here. (E.g., move the `tox` configuration [to `pyproject.toml`](https://tox.wiki/en/latest/config.html#pyproject-toml)?) -  I haven't used `tox` so I don't know


Discussion / hints:
FWIW, when I originally created this repository, "testing best practices" was explicitly excluded, because there was no consensus. While things have improved, I still don't think there's sufficient consensus that we should be worrying about tox best practices (I personally use and prefer nox).

IMO the tests here should be *examples* and we shouldn't even be running CI.

For expediency, I'd say:

1. Use whatever tox setup works to get CI to run.
2. Definitely don't put tox config in `pyproject.toml`, because that makes it harder for users to determine what's part of the "recommended config" and what's specific to this project's infrastructure.

But for better maintainability, if anyone wants to do the work, I'd support switching to nox, which doesn't need any config outside of a `noxfile.py` and which supports Python 3.7+.
> But for better maintainability, if anyone wants to do the work, I'd support switching to nox, which doesn't need any config outside of a `noxfile.py` and which supports Python 3.7+.

I'd be willing to introduce that!


Fix patch:
diff --git a/.gitignore b/.gitignore
index e81f0842..ddc2bd11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,8 @@ dist/
 __pycache__/
 *.so
 *~
+venv/
 
-# due to using tox and pytest
-.tox
+# due to using nox and pytest
+.nox
 .cache
diff --git a/noxfile.py b/noxfile.py
new file mode 100644
index 00000000..8d0c9495
--- /dev/null
+++ b/noxfile.py
@@ -0,0 +1,52 @@
+# this file is *not* meant to cover or endorse the use of nox or pytest or
+# testing in general,
+#
+#  It's meant to show the use of:
+#
+#  - check-manifest
+#     confirm items checked into vcs are in your sdist
+#  - readme_renderer (when using a reStructuredText README)
+#     confirms your long_description will render correctly on PyPI.
+#
+#  and also to help confirm pull requests to this project.
+
+import nox
+import os
+
+nox.options.sessions = ["lint"]
+
+# Define the minimal nox version required to run
+nox.options.needs_version = ">= 2024.3.2"
+
+
+@nox.session
+def lint(session):
+    session.install("flake8")
+    session.run(
+        "flake8", "--exclude", ".nox,*.egg,build,data",
+        "--select", "E,W,F", "."
+    )
+
+
+@nox.session
+def build_and_check_dists(session):
+    session.install("build", "check-manifest >= 0.42", "twine")
+    # If your project uses README.rst, uncomment the following:
+    # session.install("readme_renderer")
+
+    session.run("check-manifest", "--ignore", "noxfile.py,tests/**")
+    session.run("python", "-m", "build")
+    session.run("python", "-m", "twine", "check", "dist/*")
+
+
+@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
+def tests(session):
+    session.install("pytest")
+    build_and_check_dists(session)
+
+    generated_files = os.listdir("dist/")
+    generated_sdist = os.path.join("dist/", generated_files[1])
+
+    session.install(generated_sdist)
+
+    session.run("py.test", "tests/", *session.posargs)
diff --git a/tox.ini b/tox.ini
deleted file mode 100644
index c96f4e62..00000000
--- a/tox.ini
+++ /dev/null
@@ -1,45 +0,0 @@
-# this file is *not* meant to cover or endorse the use of tox or pytest or
-# testing in general,
-#
-#  It's meant to show the use of:
-#
-#  - check-manifest
-#     confirm items checked into vcs are in your sdist
-#  - readme_renderer (when using a ReStructuredText README)
-#     confirms your long_description will render correctly on PyPI.
-#
-#  and also to help confirm pull requests to this project.
-
-[tox]
-envlist = py{38,39,310,311,312}
-
-# Define the minimal tox version required to run;
-# if the host tox is less than this the tool with create an environment and
-# provision it with a tox that satisfies it under provision_tox_env.
-# At least this version is needed for PEP 517/518 support.
-minversion = 3.3.0
-
-# Activate isolated build environment. tox will use a virtual environment
-# to build a source distribution from the source tree. For build tools and
-# arguments use the pyproject.toml file as specified in PEP-517 and PEP-518.
-isolated_build = true
-
-[testenv]
-deps =
-    check-manifest >= 0.42
-    # If your project uses README.rst, uncomment the following:
-    # readme_renderer
-    flake8
-    pytest
-    build
-    twine
-commands =
-    check-manifest --ignore 'tox.ini,tests/**'
-    python -m build
-    python -m twine check dist/*
-    flake8 .
-    py.test tests {posargs}
-
-[flake8]
-exclude = .tox,*.egg,build,data
-select = E,W,F


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 67a77647..76651635 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -20,6 +20,8 @@ jobs:
       with:
         python-version: ${{ matrix.python }}
     - name: Install test dependencies
-      run: python -m pip install -U tox
+      run: python -m pip install --upgrade nox
     - name: Test
-      run: python -m tox -e py
+      run: python -m nox -s tests-${{ matrix.python }}
+    - name: Lint
+      run: python -m nox -s lint