1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/7cc1a4514c8e/
Changeset:   7cc1a4514c8e
User:        hpk42
Date:        2013-11-22 15:35:20
Summary:     fix issue275 - allow usefixtures and autouse fixtures
for running doctest text files.
Affected #:  4 files

diff -r a5419e5024d9719d49f7d3fc8ff1811021a106c3 -r 
7cc1a4514c8e4b8329e28c6de8a7de6174c239ec CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,9 @@
 - don't hide an ImportError when importing a plugin produces one.
   fixes issue375.
 
+- fix issue275 - allow usefixtures and autouse fixtures 
+  for running doctest text files.
+
 - fix issue380 by making --resultlog only rely on longrepr instead
   of the "reprcrash" attribute which only exists sometimes.
 

diff -r a5419e5024d9719d49f7d3fc8ff1811021a106c3 -r 
7cc1a4514c8e4b8329e28c6de8a7de6174c239ec _pytest/doctest.py
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -91,8 +91,13 @@
         doctest = py.std.doctest
         # satisfy `FixtureRequest` constructor...
         self.funcargs = {}
-        self._fixtureinfo = FuncFixtureInfo((), [], {})
+        fm = self.session._fixturemanager
+        def func():
+            pass
+        self._fixtureinfo = fm.getfixtureinfo(node=self, func=func,
+                                              cls=None, funcargs=False)
         fixture_request = FixtureRequest(self)
+        fixture_request._fillfixtures()
         failed, tot = doctest.testfile(
             str(self.fspath), module_relative=False,
             optionflags=doctest.ELLIPSIS,

diff -r a5419e5024d9719d49f7d3fc8ff1811021a106c3 -r 
7cc1a4514c8e4b8329e28c6de8a7de6174c239ec doc/en/doctest.txt
--- a/doc/en/doctest.txt
+++ b/doc/en/doctest.txt
@@ -56,3 +56,7 @@
     # content of example.rst
     >>> tmp = getfixture('tmpdir')
     >>> ...
+    >>>
+
+Also, :ref:`usefixtures` and :ref:`autouse` fixtures are supported
+when executing text doctest files.

diff -r a5419e5024d9719d49f7d3fc8ff1811021a106c3 -r 
7cc1a4514c8e4b8329e28c6de8a7de6174c239ec testing/test_doctest.py
--- a/testing/test_doctest.py
+++ b/testing/test_doctest.py
@@ -209,6 +209,26 @@
         reprec = testdir.inline_run(p, )
         reprec.assertoutcome(passed=1)
 
+    @xfail_if_pdbpp_installed
+    def test_txtfile_with_usefixtures_in_ini(self, testdir):
+        testdir.makeini("""
+            [pytest]
+            usefixtures = myfixture
+        """)
+        testdir.makeconftest("""
+            import pytest
+            @pytest.fixture
+            def myfixture(monkeypatch):
+                monkeypatch.setenv("HELLO", "WORLD")
+        """)
+
+        p = testdir.maketxtfile("""
+            >>> import os
+            >>> os.environ["HELLO"]
+            'WORLD'
+        """)
+        reprec = testdir.inline_run(p, )
+        reprec.assertoutcome(passed=1)
 
     @xfail_if_pdbpp_installed
     def test_doctestmodule_with_fixtures(self, testdir):

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to