@@ -134,18 +134,19 @@ def tests(session: PowerSession, coverage, pkg_specs):
134134 # session.run2("conda list", env={"CONDA_PREFIX": str(conda_prefix), "CONDA_DEFAULT_ENV": session.get_session_id()})
135135
136136 # Fail if the assumed python version is not the actual one
137- session .run2 ("python ci_tools/check_python_version.py %s" % session .python )
137+ session .run2 (f "python ci_tools/check_python_version.py { session .python } " )
138138
139139 # check that it can be imported even from a different folder
140- # session.run2(['python', '-c', '"import os; os.chdir(\'./docs/\'); import %s"' % pkg_name])
140+ # Important: do not surround the command into double quotes as in the shell !
141+ # session.run('python', '-c', 'import os; os.chdir(\'./docs/\'); import %s' % pkg_name)
141142
142143 # finally run all tests
143144 if not coverage :
144145 # install self so that it is recognized by pytest
145146 session .run2 ("pip install . --no-deps" )
146147
147148 # simple: pytest only
148- session .run2 ("python -m pytest --cache-clear -v %s /tests/" % pkg_name )
149+ session .run2 (f "python -m pytest --cache-clear -v { pkg_name } /tests/" )
149150 else :
150151 # install self in "develop" mode so that coverage can be measured
151152 session .run2 ("pip install -e . --no-deps" )
@@ -159,28 +160,28 @@ def tests(session: PowerSession, coverage, pkg_specs):
159160
160161 # First the raw for coverage
161162 print ("\n \n ****** Running tests : 1/2 RAW (for coverage) ******\n \n " )
162- session .run2 ("coverage run --source {pkg_name} "
163- "-m pytest --cache-clear -v {pkg_name}/tests_raw/"
164- "" .format (pkg_name = pkg_name ),
163+ session .run2 (f"coverage run --source { pkg_name } "
164+ f"-m pytest --cache-clear -v { pkg_name } /tests_raw/" ,
165165 success_codes = (0 , 1 ) # since some tests are purposedly failing we accept code 1
166166 )
167167
168168 print ("\n \n ****** Running tests : 2/2 META (appending to coverage) ******\n \n " )
169- session .run2 ("coverage run --append --source {pkg_name} "
170- "-m pytest --junitxml={test_xml} --html={test_html} -v {pkg_name}/tests/"
171- "" .format (pkg_name = pkg_name , test_xml = Folders .test_xml , test_html = Folders .test_html ))
169+ session .run2 (f"coverage run --append --source { pkg_name } "
170+ "-m pytest "
171+ f'--junitxml="{ Folders .test_xml } " --html="{ Folders .test_html } " '
172+ f"-v { pkg_name } /tests/" )
172173
173174 # session.run2("coverage report") # this shows in terminal + fails under XX%, same as --cov-report term --cov-fail-under=70 # noqa
174- session .run2 (" coverage xml -o {covxml}" . format ( covxml = Folders .coverage_xml ) )
175- session .run2 (" coverage html -d {dst}" . format ( dst = Folders .coverage_reports ) )
175+ session .run2 (f' coverage xml -o " { Folders .coverage_xml } "' )
176+ session .run2 (f' coverage html -d " { Folders .coverage_reports } "' )
176177 # delete this intermediate file, it is not needed anymore
177178 rm_file (Folders .coverage_intermediate_file )
178179
179180 # --generates the badge for the test results and fail build if less than x% tests pass
180181 nox_logger .info ("Generating badge for tests coverage" )
181182 # Use our own package to generate the badge
182- session .run2 (" genbadge tests -i %s -o %s -t 100" % ( Folders . test_xml , Folders . test_badge ) )
183- session .run2 (" genbadge coverage -i %s -o %s" % ( Folders .coverage_xml , Folders . coverage_badge ) )
183+ session .run2 (f' genbadge tests -i " { Folders . test_xml } " -o " { Folders . test_badge } " -t 100' )
184+ session .run2 (f' genbadge coverage -i " { Folders . coverage_xml } " -o " { Folders .coverage_badge } "' )
184185
185186
186187@power_session (python = PY39 , logsdir = Folders .runlogs )
@@ -198,7 +199,7 @@ def flake8(session: PowerSession):
198199 session .run ("flake8" , pkg_name , "--exit-zero" , "--format=html" , "--htmldir" , str (Folders .flake8_reports ),
199200 "--statistics" , "--tee" , "--output-file" , str (Folders .flake8_intermediate_file ))
200201 # generate our badge
201- session .run2 (" genbadge flake8 -i %s -o %s" % ( Folders .flake8_intermediate_file , Folders . flake8_badge ) )
202+ session .run2 (f' genbadge flake8 -i " { Folders . flake8_intermediate_file } " -o " { Folders .flake8_badge } "' )
202203 rm_file (Folders .flake8_intermediate_file )
203204
204205
@@ -289,10 +290,9 @@ def my_scheme(version_):
289290
290291 # create the github release
291292 session .install_reqs (phase = "release" , phase_reqs = ["click" , "PyGithub" ])
292- session .run2 ("python ci_tools/github_release.py -s {gh_token} "
293- "--repo-slug {gh_org}/{gh_repo} -cf ./docs/changelog.md "
294- "-d https://{gh_org}.github.io/{gh_repo}/changelog {tag}"
295- "" .format (gh_token = gh_token , gh_org = gh_org , gh_repo = gh_repo , tag = current_tag ))
293+ session .run2 (f"python ci_tools/github_release.py -s { gh_token } "
294+ f"--repo-slug { gh_org } /{ gh_repo } -cf ./docs/changelog.md "
295+ f"-d https://{ gh_org } .github.io/{ gh_repo } /changelog { current_tag } " )
296296
297297
298298@nox .session (python = False )
@@ -321,18 +321,18 @@ def gha_list(session):
321321 session_func .parametrize
322322 except AttributeError :
323323 if additional_args .with_version :
324- sessions_list = [{"python" : py , "session" : "%s-%s" % ( session_func .__name__ , py ) } for py in session_func .python ]
324+ sessions_list = [{"python" : py , "session" : f" { session_func .__name__ } - { py } " } for py in session_func .python ]
325325 else :
326- sessions_list = ["%s-%s" % ( session_func .__name__ , py ) for py in session_func .python ]
326+ sessions_list = [f" { session_func .__name__ } - { py } " for py in session_func .python ]
327327 else :
328328 if additional_args .with_version :
329- # sessions_list = [{"python": py, "session": "%s-%s(%s)" % ( session_func.__name__, py, param) }
329+ # sessions_list = [{"python": py, "session": f"{ session_func.__name__}-{py}({ param})" }
330330 # for py, param in product(session_func.python, session_func.parametrize)]
331331 # Hack to return the valid ones only, in order # TODO remove this hack when ENV is removed
332- sessions_list = [{"python" : py , "session" : "%s-%s (env='%s ')" % ( session_func . __name__ , py , env ) }
332+ sessions_list = [{"python" : py , "session" : f" { session_func . __name__ } - { py } (env='{ env } ')" }
333333 for py , env in ENVS .keys ()]
334334 else :
335- sessions_list = ["%s-%s(%s)" % ( session_func .__name__ , py , param )
335+ sessions_list = [f" { session_func .__name__ } - { py } ( { param } )"
336336 for py , param in product (session_func .python , session_func .parametrize )]
337337
338338 # print the list so that it can be caught by GHA.
0 commit comments