Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
38 views

How do you pass options to doctest when running 'make doctest' from Sphinx?

We use make html to build HTML docs from .rst docs and our Python code using Sphinx. We have also enabled the sphinx.ext.doctest extension in Sphinx so that we can test any code samples in our docs by ...
snark's user avatar
  • 2,887
1 vote
0 answers
98 views

How to make sphinx-apidoc, doctest and -W option play together nicely?

My current pipeline looks something like the following: sphinx-build -b doctest -d docs/build/doctrees docs docs/build/doctest sphinx-apidoc -f -o docs/ src/my_package sphinx-build -b html -d docs/...
Mr-Pepe's user avatar
  • 87
1 vote
1 answer
439 views

Doctest not working in Sphinx, cannot import python files Python

I have a problem trying to run doctest from the Sphinx Tutorial. I have the directory tree below but I cannot run a doctest for lumache.py. How would be able to make it so that lumache.py is ...
Bosser445's user avatar
  • 353
2 votes
0 answers
197 views

Way to exclude directories when running make doctest

I have a python library which uses Sphinx to build documentation pages. The library structure is as follows: Library-name |- /docs | |- <lots of .rst files> | |- config.py | |- /src | |- <...
Matthew Giammar's user avatar
6 votes
0 answers
262 views

Combining doctest and Matplotlib Sphinx extensions

The Sphinx extension sphinx.ext.doctest makes it straightforward to ensure that your documentation is up to date. At the same time, the matplotlib.sphinxext.plot_directive extension makes it ...
fuglede's user avatar
  • 18.2k
1 vote
0 answers
77 views

Sphinx runs doctests multiple times due to 'from X import Y'

I have a project set up to run doctests from Sphinx, via automodule. However, it appears that not only do the module's tests get run, so does anything with the syntax of: from some.module.path import ...
Zach Riggle's user avatar
  • 3,055
0 votes
1 answer
191 views

How to get Sphinx doctest to reset the Django database after each test?

[TL;DR] When using Sphinx's make doctest, Django models created in tests are committed to the database; how do we prevent them auto-committing or to reset the database between each test (using a ...
MT0's user avatar
  • 167k
0 votes
0 answers
56 views

How to exclude `.. testcode::` in make html

I've a small python and just a few of these files have the .. testcode:: directive in order to test the python code. Is there any way to exclude all the tests when invoking make html?
matteo's user avatar
  • 4,863
4 votes
0 answers
386 views

Get Test Coverage Sphinx "testcode" Directive

I have a number of tests in my Sphinx document. I choose to use the .. testcode:: directive over the .. doctest:: directive and standard doctest syntax because I want the output to resemble standard ...
10SecTom's user avatar
  • 2,644
2 votes
1 answer
756 views

doctest running in sphinx doc

I am trying to run doctest written in my rst doc. But I can't get how to run it. I've written the following: .. doctest:: >>> 43 + 1 45 And then I do: $ make html but doc is ...
LinearLeopard's user avatar
3 votes
4 answers
4k views

Use Sphinx doctest with :Example:

Consider the following function: # in mymodule.py: def myfunc(num,mystring): """ replicates a string :param num: a positive integer :param mystring: a string :return: string ...
l7ll7's user avatar
  • 1,329
0 votes
1 answer
94 views

Doctest thinks DocTestParser doesn't exist?

I'm trying to use sphinx to create documentation. I'm currently following this tutorial from PyCon 2016 by Eric Holscher. During step two is the first time autodocs is used. I set the file path to ...
LukeDev's user avatar
  • 541
1 vote
1 answer
586 views

Sphinx not removing doctest flags in html output

I cannot eliminate the doctest flags (ie. <BLANKLINE>, # doctest: +ELLIPSIS) for the html output. I am able to generate the documentation as I would like, so no errors there but it includes ...
dshanahan's user avatar
  • 734
6 votes
0 answers
292 views

Run both doctests and normal tests with Pytest

In my Python project, I'm using Pytest. The directory structure is: src/ docs/ test/ I have a different kind of tests: normal tests, in test/* doctests in the source, src/* doctests in ...
Marco Favorito's user avatar
4 votes
0 answers
98 views

Python-Sphinx: docstring code-testing along with running code by IPython directive?

Sphinx supports a doctest directive, for including tests of code within docstrings. The code is displayed with the >>> prompt of the standard Python interpreter. Sphinx also supports an ...
brannerchinese's user avatar
0 votes
0 answers
229 views

Sphinx doctest fails while exactly the same for Got and Expected

I got this fail report: Document: readme ---------------- ********************************************************************** File "readme.rst", line ?, in default Failed example: a Expected: ...
Bastiaan's user avatar
  • 4,642
1 vote
1 answer
1k views

Can autodoc be used to execute code from docstring?

When using Sphinx and autodoc to document a Python project, you can use :Example: to include a code sample in your module/class/function docstring, which Sphinx will kindly syntax highlight for you. ...
Daniel Standage's user avatar
1 vote
1 answer
470 views

How can I test output of non-ASCII characters using Sphinx doctest?

I'm at a loss how to test printing output that includes non-ASCII characters using Sphinx doctest. When I have test that include code that generates non-ASCII characters, or that contains expected ...
orome's user avatar
  • 48.3k
1 vote
1 answer
474 views

In Python Sphinx, is there a way to hide autodoc setup code?

I am using Sphinx autodoc to document my Python code. Examples in my documentation contain: Uninteresting set up code I do not want rendered in the HTML documentation Code that should appear in the ...
John McGehee's user avatar
  • 10.2k
3 votes
1 answer
888 views

How can I run Sphinx doctests as part of setup.py?

I want to include a setuptools command to run Sphinx doctest as part of my package setup.py, like this: $ python setup.py sphinx_doctest I have a package structure like: my_pkg |---__init__.py |---...
Leo's user avatar
  • 1,107
3 votes
1 answer
1k views

Why could doctests raise a NameError when run with Sphinx's `make doctest`?

I have a simple function with a doctest, which, when run with Sphinx's make doctest, gives me the following error: File "scheemey.rst", line ?, in default Failed example: verify_balanced('asdf (...
Andrey Fedorov's user avatar
2 votes
2 answers
304 views

Disable nose running setup()

The nose package is often used to run doctests as well as tests in dedicated test files. It appears that even in doctest files, it attempts to run the setup and teardown fixtures. When the module for ...
joeln's user avatar
  • 3,633
3 votes
3 answers
179 views

How to make Sphinx understand Sage doctests?

I have a package that is primarily Python, and mostly meant to be used with Python. But also there are a few extra functions that are available when the module is used under Sage. The problem is ...
Dan Stahlke's user avatar
  • 1,459
11 votes
2 answers
588 views

Is there a way to use doctest and sphinx to test and document command line applications?

I have a Python module for which I'm writing a tutorial using Sphinx including doctests. This module comes with a few helper programs. I would like to include those helper programs in the ...
ascobol's user avatar
  • 7,686
5 votes
1 answer
307 views

prevent sphinx from executing inherited doctests

We've made a library which uses massively (with inheritance) numpy's MaskedArrays. But I want to run sphinx's make doctest without testing the inherited methods from numpy, because they make round ...
Themerius's user avatar
  • 1,911
12 votes
3 answers
5k views

Auto generate doctest output with Sphinx extension

I think I am missing something about the sphinx extension for doctest. The typical example in the documentation is: .. doctest:: >>> print 1 1 Isn't there a way to let sphinx ...
user1283990's user avatar
2 votes
1 answer
908 views

Python doctests / sphinx : style guide, how to use those and have a readable code?

I love doctests, it is the only testing framwork I use, because it is so quick to write, and because used with sphinx it makes such great documentations with almost no effort... However, very often, ...
sebpiq's user avatar
  • 7,762