@@ -92,6 +92,15 @@ def parametrize_test_versions():
9292PARAMETRIZED_TEST_VERSIONS = parametrize_test_versions ()
9393
9494
95+ def install_dependencies (session , session_name , sqlalchemy_version ):
96+ """Install dependencies for the given session."""
97+ session .install (
98+ "-r" , f"requirements-{ session_name } .txt" ,
99+ f"sqlalchemy~={ sqlalchemy_version } .0" ,
100+ "-e" , "."
101+ )
102+
103+
95104@nox .session ()
96105@nox .parametrize ("python,sqlalchemy" , PARAMETRIZED_TEST_VERSIONS )
97106def test (session , sqlalchemy ):
@@ -109,9 +118,7 @@ def test(session, sqlalchemy):
109118
110119 For fine-grained control over running the tests, refer the nox documentation: https://nox.thea.codes/en/stable/usage.html
111120 """
112- session .install ("-r" , "requirements-test.txt" )
113- session .install (f"sqlalchemy~={ sqlalchemy } .0" )
114- session .install ("-e" , "." )
121+ install_dependencies (session , "test" , sqlalchemy )
115122 pytest_args = session .posargs or ["--pyargs" , "sqlalchemy_mptt" ]
116123 session .run ("pytest" , * pytest_args , env = {"SQLALCHEMY_WARN_20" : "1" })
117124
@@ -120,9 +127,7 @@ def test(session, sqlalchemy):
120127@nox .parametrize ("python,sqlalchemy" , PARAMETRIZED_TEST_VERSIONS [- 1 :])
121128def doctest (session , sqlalchemy ):
122129 """Run doctests in the documentation."""
123- session .install ("sphinx" )
124- session .install (f"sqlalchemy~={ sqlalchemy } .0" )
125- session .install ("-e" , "." )
130+ install_dependencies (session , "doctest" , sqlalchemy )
126131 session .run ("sphinx-build" , "-b" , "doctest" , "docs" , "docs/_build" )
127132
128133
0 commit comments