2525 $ uv run noxfile.py
2626 Run all tests with coverage and linting:
2727 $ uv run noxfile.py -- --coverage
28+ Run tests for a specific SQLAlchemy version:
29+ $ uv run noxfile.py -t sqla12
30+ Run tests for a specific Python version:
31+ $ uv run noxfile.py -s test -p 3.X
32+ $ uv run noxfile.py -s test -p pypy-3.X # For PyPy
2833
2934 Set up a development environment with the default Python version (3.8):
3035 $ uv run noxfile.py -s dev
@@ -56,7 +61,7 @@ def lint(session):
5661 "flake8" , "." , "--count" , "--select=E9,F63,F7,F82" , "--show-source" , "--statistics" , "--extend-exclude" , ".venv" )
5762 # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
5863 session .run (
59- "flake8" , "." , "--count" , "--exit-zero" , "--max-complexity=10" ,
64+ "flake8" , "." , "--count" , "--exit-zero" , "--max-complexity=10" , "--extend-ignore=E711" ,
6065 "--max-line-length=127" , "--statistics" , "--extend-exclude" , ".venv" )
6166
6267
@@ -81,7 +86,10 @@ def parametrize_test_versions():
8186 ]
8287
8388 return [
84- (f"{ interpreter } 3.{ python_minor } " , str (sqlalchemy_version ))
89+ nox .param (
90+ f"{ interpreter } 3.{ python_minor } " , str (sqlalchemy_version ),
91+ tags = [f"sqla{ sqlalchemy_version .major } { sqlalchemy_version .minor } " ]
92+ )
8593 for interpreter in ("" , "pypy-" )
8694 for python_minor in range (PYTHON_MINOR_VERSION_MIN , PYTHON_MINOR_VERSION_MAX + 1 )
8795 for sqlalchemy_version in filtered_sqlalchemy_versions
@@ -95,15 +103,27 @@ def test(session, sqlalchemy):
95103 """Run tests with pytest.
96104
97105 Use the --coverage option to run tests with coverage.
106+
107+ For running tests for a specific SQLAlchemy version, use the tags option:
108+
109+ $ uv run noxfile.py -s test -t sqla12
110+
98111 For fine-grained control over running the tests, refer the nox documentation: https://nox.thea.codes/en/stable/usage.html
99112 """
100113 session .install ("-r" , "requirements-test.txt" )
101114 session .install (f"sqlalchemy~={ sqlalchemy } .0" )
102- if "--coverage" in session .posargs :
103- session .run ("coverage" , "run" , "--source=sqlalchemy_mptt" , "-m" , "pytest" , "sqlalchemy_mptt/" )
104- session .run ("coverage" , "xml" )
115+ session .install ("-e" , "." )
116+ try :
117+ session .posargs .remove ("--coverage" )
118+ except ValueError :
119+ with_coverage = False
105120 else :
106- session .run ("pytest" , "sqlalchemy_mptt/" )
121+ with_coverage = True
122+ pytest_cmd = [
123+ "pytest" , "--pyargs" , "sqlalchemy_mptt" ,
124+ "--cov" , "sqlalchemy_mptt" , "--cov-report" , "term-missing:skip-covered"
125+ ] + ["--cov-report" , "xml" ] if with_coverage else [] + session .posargs
126+ session .run (* pytest_cmd )
107127
108128
109129@nox .session (default = False )
0 commit comments