Skip to content

Commit

Permalink
tox-to-nox: support descriptions (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbarrett committed Feb 17, 2022
1 parent 5cab407 commit d15dde9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nox/tox_to_nox.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import nox
{% for envname, envconfig in config.envconfigs.items()|sort: %}
@nox.session({%- if envconfig.basepython %}python='{{envconfig.basepython}}'{%- endif %})
def {{fixname(envname)}}(session):
{%- if envconfig.description != '' %}
"""{{envconfig.description}}"""
{%- endif %}
{%- set envs = dict(envconfig.setenv) -%}
{%- do envs.pop('PYTHONHASHSEED', None) -%}
{%- do envs.pop('TOX_ENV_DIR', None) -%}
Expand Down
32 changes: 32 additions & 0 deletions tests/test_tox_to_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,35 @@ def test_with_&(session):
== "Environment 'test_with_&' is not a valid nox session name.\n"
"Manually update the session name in noxfile.py before running nox.\n"
)


def test_descriptions_into_docstrings(makeconfig):
result = makeconfig(
textwrap.dedent(
"""
[tox]
envlist = lint
[testenv:lint]
basepython = python2.7
description =
runs the lint action
now with an unnecessary second line
"""
)
)

assert (
result
== textwrap.dedent(
"""
import nox
@nox.session(python='python2.7')
def lint(session):
\"\"\"runs the lint action now with an unnecessary second line\"\"\"
session.install('.')
"""
).lstrip()
)

0 comments on commit d15dde9

Please sign in to comment.