8 new commits in pytest:
https://bitbucket.org/hpk42/pytest/commits/8fe255a64587/
changeset: 8fe255a64587
branch: doctest-fixtures
user: witsch
date: 2013-01-30 17:32:37
summary: pass fixture request object (and convenience shortcut to get
fixtures) into doctest files
affected #: 1 file
diff -r 4c071ec6f091658d94aed3a8c6b647c9a97159b8 -r
8fe255a6458719115c6f3a3b08afda16b8cd7e37 _pytest/doctest.py
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -1,6 +1,7 @@
""" discover and run doctests in modules and test files."""
import pytest, py
+from _pytest.python import FixtureRequest, FuncFixtureInfo
from py._code.code import TerminalRepr, ReprFileLocation
def pytest_addoption(parser):
@@ -70,9 +71,15 @@
class DoctestTextfile(DoctestItem, pytest.File):
def runtest(self):
doctest = py.std.doctest
+ # satisfy `FixtureRequest` constructor...
+ self.funcargs = {}
+ self._fixtureinfo = FuncFixtureInfo((), [], {})
+ fixture_request = FixtureRequest(self)
failed, tot = doctest.testfile(
str(self.fspath), module_relative=False,
optionflags=doctest.ELLIPSIS,
+ extraglobs=dict(fixture_request=fixture_request,
+ get_fixture=fixture_request.getfuncargvalue),
raise_on_error=True, verbose=0)
class DoctestModule(DoctestItem, pytest.File):
https://bitbucket.org/hpk42/pytest/commits/845b874d0279/
changeset: 845b874d0279
branch: doctest-fixtures
user: witsch
date: 2013-03-20 16:36:48
summary: don't expose the `FixtureRequest` object itself in doctests. in
most cases `get_fixture` is sufficient, and you can always call
`get_fixture('request')` anyway
affected #: 1 file
diff -r 8fe255a6458719115c6f3a3b08afda16b8cd7e37 -r
845b874d0279066996b0003ecca98c628aafa962 _pytest/doctest.py
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -78,8 +78,7 @@
failed, tot = doctest.testfile(
str(self.fspath), module_relative=False,
optionflags=doctest.ELLIPSIS,
- extraglobs=dict(fixture_request=fixture_request,
- get_fixture=fixture_request.getfuncargvalue),
+ extraglobs=dict(get_fixture=fixture_request.getfuncargvalue),
raise_on_error=True, verbose=0)
class DoctestModule(DoctestItem, pytest.File):
https://bitbucket.org/hpk42/pytest/commits/42e91cdf91ed/
changeset: 42e91cdf91ed
branch: doctest-fixtures
user: witsch
date: 2013-03-20 17:14:28
summary: test `get_fixture` helper for doctests
affected #: 1 file
diff -r 845b874d0279066996b0003ecca98c628aafa962 -r
42e91cdf91ed8aa448d6a4c4f995d620985e2b11 testing/test_doctest.py
--- a/testing/test_doctest.py
+++ b/testing/test_doctest.py
@@ -124,3 +124,12 @@
" 1",
"*test_txtfile_failing.txt:2: DocTestFailure"
])
+
+ def test_txtfile_with_fixtures(self, testdir, tmpdir):
+ p = testdir.maketxtfile("""
+ >>> dir = get_fixture('tmpdir')
+ >>> type(dir).__name__
+ 'LocalPath'
+ """)
+ reprec = testdir.inline_run(p, )
+ reprec.assertoutcome(passed=1)
https://bitbucket.org/hpk42/pytest/commits/aef8c6257507/
changeset: aef8c6257507
branch: doctest-fixtures
user: witsch
date: 2013-03-20 17:32:48
summary: also provide `get_fixture` helper for module level doctests
affected #: 2 files
diff -r 42e91cdf91ed8aa448d6a4c4f995d620985e2b11 -r
aef8c6257507b79fe5843562889b2d6ac8017455 _pytest/doctest.py
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -88,6 +88,11 @@
module = self.config._conftest.importconftest(self.fspath)
else:
module = self.fspath.pyimport()
+ # satisfy `FixtureRequest` constructor...
+ self.funcargs = {}
+ self._fixtureinfo = FuncFixtureInfo((), [], {})
+ fixture_request = FixtureRequest(self)
failed, tot = doctest.testmod(
module, raise_on_error=True, verbose=0,
+ extraglobs=dict(get_fixture=fixture_request.getfuncargvalue),
optionflags=doctest.ELLIPSIS)
diff -r 42e91cdf91ed8aa448d6a4c4f995d620985e2b11 -r
aef8c6257507b79fe5843562889b2d6ac8017455 testing/test_doctest.py
--- a/testing/test_doctest.py
+++ b/testing/test_doctest.py
@@ -133,3 +133,14 @@
""")
reprec = testdir.inline_run(p, )
reprec.assertoutcome(passed=1)
+
+ def test_doctestmodule_with_fixtures(self, testdir, tmpdir):
+ p = testdir.makepyfile("""
+ '''
+ >>> dir = get_fixture('tmpdir')
+ >>> type(dir).__name__
+ 'LocalPath'
+ '''
+ """)
+ reprec = testdir.inline_run(p, "--doctest-modules")
+ reprec.assertoutcome(passed=1)
https://bitbucket.org/hpk42/pytest/commits/08b5b1589954/
changeset: 08b5b1589954
branch: doctest-fixtures
user: witsch
date: 2013-03-20 17:54:38
summary: update the documentation regarding the `get_fixture` helper
please note that the japanese translation was done using "google translate" and
should probably be checked again... :)
affected #: 2 files
Diff not available.
https://bitbucket.org/hpk42/pytest/commits/7c165e6e429a/
changeset: 7c165e6e429a
branch: doctest-fixtures
user: witsch
date: 2013-03-21 01:03:59
summary: remove debugging left-overs
affected #: 1 file
Diff not available.
https://bitbucket.org/hpk42/pytest/commits/91495671c0d1/
changeset: 91495671c0d1
branch: doctest-fixtures
user: witsch
date: 2013-03-21 12:04:14
summary: rename `get_fixture` to `getfixture` to better match the current
API style
affected #: 4 files
Diff not available.
https://bitbucket.org/hpk42/pytest/commits/56fb27ee91c7/
changeset: 56fb27ee91c7
user: hpk42
date: 2013-03-21 12:33:43
summary: Merged in witsch/pytest/doctest-fixtures (pull request #25)
fixture support in doctests
affected #: 4 files
Diff not available.
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
[email protected]
http://mail.python.org/mailman/listinfo/pytest-commit