From fcbe9bad8ba3372ffc3fd9cda495c84c57631a23 2017-11-20 21:53:47 From: Doug Latornell Date: 2017-11-20 21:53:47 Subject: [PATCH] Change return type in docstring to literal tuple to avoid bogus cross-ref. Before this change the Sphinx tried to produce cross-reference links for the returned (stdout, stderr) tuple. The docs build produced a warning because there are 2 possible cross-ref objects for `stdout`, one in `IPython.testing.iptestcontroller.TestController`, the other in `IPython.utils.capture.CapturedIO`. Neither of those is correct in the context of the `ipexec()` function. Changing literal ``(stdout, stderr)`` avoids the warning by preventing the attempt to produce cross-references. --- diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index b4e570b..70be93b 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -87,7 +87,7 @@ def parse_test_output(txt): txt : str Text output of a test run, assumed to contain a line of one of the following forms:: - + 'FAILED (errors=1)' 'FAILED (failures=1)' 'FAILED (errors=1, failures=1)' @@ -186,7 +186,7 @@ def ipexec(fname, options=None, commands=()): Returns ------- - (stdout, stderr) of ipython subprocess. + ``(stdout, stderr)`` of ipython subprocess. """ if options is None: options = [] @@ -333,13 +333,13 @@ notprinted_msg = """Did not find {0!r} in printed output (on {1}): class AssertPrints(object): """Context manager for testing that code prints certain text. - + Examples -------- >>> with AssertPrints("abc", suppress=False): ... print("abcd") ... print("def") - ... + ... abcd def """ @@ -349,13 +349,13 @@ class AssertPrints(object): self.s = [self.s] self.channel = channel self.suppress = suppress - + def __enter__(self): self.orig_stream = getattr(sys, self.channel) self.buffer = MyStringIO() self.tee = Tee(self.buffer, channel=self.channel) setattr(sys, self.channel, self.buffer if self.suppress else self.tee) - + def __exit__(self, etype, value, traceback): try: if value is not None: @@ -381,7 +381,7 @@ printed_msg = """Found {0!r} in printed output (on {1}): class AssertNotPrints(AssertPrints): """Context manager for checking that certain output *isn't* produced. - + Counterpart of AssertPrints""" def __exit__(self, etype, value, traceback): try: