Repository: davidvilla/python-doublex (language: python)

Issue:
Run doctests on CI
Currently, the doctests are not executed on CI. Having them run on each PR would give more confidence that they work.


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 1aa91ed..e1a0997 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
 *.egg-info
 dist
 build
+_build
 eggs
 parts
 bin
@@ -27,6 +28,8 @@ pip-log.txt
 .tox
 nosetests.xml
 
+doctests/*.inc
+
 # Translations
 *.mo
 
diff --git a/docs/Makefile b/docs/Makefile
index 3cc2177..3def24a 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -2,7 +2,7 @@
 #
 
 # You can set these variables from the command line.
-SPHINXOPTS    =
+SPHINXOPTS    = -W
 SPHINXBUILD   = sphinx-build
 PAPER         =
 BUILDDIR      = _build
diff --git a/docs/async-spies.rst b/docs/async-spies.rst
index 2d5a96e..8f38d32 100644
--- a/docs/async-spies.rst
+++ b/docs/async-spies.rst
@@ -1,4 +1,4 @@
-.. async_mode:
+.. _async_mode:
 
 Asynchronous spies
 ==================
@@ -17,7 +17,7 @@ Something like that:
 
    class Collaborator(object):
        def write(self, data):
-           print "your code here"
+           print("your code here")
 
    class SUT(object):
        def __init__(self, collaborator):
diff --git a/docs/conf.py b/docs/conf.py
index b174ba1..1ae9ca4 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -126,7 +126,7 @@
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = []
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
diff --git a/tox.ini b/tox.ini
index f6dc9a3..4cbe471 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py36, py37, py38, py39, py310
+envlist = py36, py37, py38, py39, py310, docs
 
 [testenv]
 deps=nose2
@@ -11,7 +11,15 @@ python =
     3.7: py37
     3.8: py38
     3.9: py39
-    3.10: py310
+    3.10: py310, docs
+
+[testenv:docs]
+allowlist_externals = make
+deps = sphinx
+commands =
+    make -C docs
+    make -C doctests
+
 
 # using 2to3 with nose
 #:https://bitbucket.org/kumar303/fudge/src/9cafce359a21/tox.ini#cl-26


Test patch:
diff --git a/docs/async-spies.rst.test b/docs/async-spies.rst.test
index d156ea9..c5df39b 100644
--- a/docs/async-spies.rst.test
+++ b/docs/async-spies.rst.test
@@ -1,4 +1,4 @@
-.. async_mode:
+.. _async_mode:
 
 Asynchronous spies
 ==================
@@ -17,7 +17,7 @@ Something like that:
 
    class Collaborator(object):
        def write(self, data):
-           print "your code here"
+           print("your code here")
 
    class SUT(object):
        def __init__(self, collaborator):
diff --git a/docs/doubles.rst.test b/docs/doubles.rst.test
index cc22c04..87b7216 100644
--- a/docs/doubles.rst.test
+++ b/docs/doubles.rst.test
@@ -248,13 +248,14 @@ sequence does not match, an AssertionError is raised. "free" mocks are provided
 .. testcode::
 .. sourcecode:: python
 
-   from doublex import Mock, assert_that, verify
+   from doublex import ANY_ARG, Mock, assert_that, verify
 
    with Mock() as smtp:
        smtp.helo()
        smtp.mail(ANY_ARG)
        smtp.rcpt("bill@apple.com")
-       smtp.data(ANY_ARG).returns(True).times(2)
+       smtp.data(ANY_ARG)
+       smtp.data(ANY_ARG)
 
    smtp.helo()
    smtp.mail("poormen@home.net")
diff --git a/doctests/Makefile b/doctests/Makefile
index 4012433..cd6c4b1 100644
--- a/doctests/Makefile
+++ b/doctests/Makefile
@@ -2,7 +2,7 @@
 #
 
 # You can set these variables from the command line.
-SPHINXOPTS    =
+SPHINXOPTS    = -W
 SPHINXBUILD   = sphinx-build
 PAPER         =
 BUILDDIR      = _build
diff --git a/doctests/conf.py b/doctests/conf.py
index e285151..1ce34a2 100644
--- a/doctests/conf.py
+++ b/doctests/conf.py
@@ -120,7 +120,7 @@
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = []
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.