Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-flake8-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Jul 19, 2017
2 parents 24da938 + c92760d commit d44565f
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 287 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Marcin Bachry
Mark Abramowitz
Markus Unterwaditzer
Martijn Faassen
Martin Altmayer
Martin K. Scherer
Martin Prusse
Mathieu Clabaut
Expand Down
254 changes: 0 additions & 254 deletions _pytest/impl

This file was deleted.

26 changes: 20 additions & 6 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import os
import collections
from textwrap import dedent
from itertools import count

import math
Expand Down Expand Up @@ -994,14 +995,12 @@ def write_fixture(fixture_def):
funcargspec = argname
tw.line(funcargspec, green=True)

INDENT = ' {0}'
fixture_doc = fixture_def.func.__doc__

if fixture_doc:
for line in fixture_doc.strip().split('\n'):
tw.line(INDENT.format(line.strip()))
write_docstring(tw, fixture_doc)
else:
tw.line(INDENT.format('no docstring available'), red=True)
tw.line(' no docstring available', red=True)

def write_item(item):
name2fixturedefs = item._fixtureinfo.name2fixturedefs
Expand Down Expand Up @@ -1075,13 +1074,28 @@ def _showfixtures_main(config, session):
loc = getlocation(fixturedef.func, curdir)
doc = fixturedef.func.__doc__ or ""
if doc:
for line in doc.strip().split("\n"):
tw.line(" " + line.strip())
write_docstring(tw, doc)
else:
tw.line(" %s: no docstring available" % (loc,),
red=True)


def write_docstring(tw, doc):
INDENT = " "
doc = doc.rstrip()
if "\n" in doc:
firstline, rest = doc.split("\n", 1)
else:
firstline, rest = doc, ""

if firstline.strip():
tw.line(INDENT + firstline.strip())

if rest:
for line in dedent(rest).split("\n"):
tw.write(INDENT + line + "\n")


# builtin pytest.raises helper

def raises(expected_exception, *args, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions changelog/2574.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The options --fixtures and --fixtures-per-test will now keep indentation within docstrings.
1 change: 1 addition & 0 deletions changelog/971.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extend documentation for testing plugin code with the ``pytester`` plugin.
Loading

0 comments on commit d44565f

Please sign in to comment.