diff --git a/nox/tox_to_nox.jinja2 b/nox/tox_to_nox.jinja2 index 1444607f..1e22ca89 100644 --- a/nox/tox_to_nox.jinja2 +++ b/nox/tox_to_nox.jinja2 @@ -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) -%} diff --git a/tests/test_tox_to_nox.py b/tests/test_tox_to_nox.py index f676cab6..c7b54850 100644 --- a/tests/test_tox_to_nox.py +++ b/tests/test_tox_to_nox.py @@ -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() + )