From e94a602e593c26f46ef14d82b30549376faef1a5 Mon Sep 17 00:00:00 2001 From: hpk Date: Wed, 24 Jan 2007 17:39:49 +0100 Subject: [PATCH] [svn r37271] merging of file:///svn/py/branch/config/py/doc/test_conftest.py revisions 36936 to 37267: ------------------------------------------------------------------------ r37074 | hpk | 2007-01-20 21:43:52 +0100 (Sat, 20 Jan 2007) | 9 lines * config.initsession() deals with getting at a session class and initiliazing it * config._getcollector(path) gets a collector pointing to path * added lots of tests * thus remove the strange getfscollector and map2colitems logic * mark some tkinter tests as skipped * fixing things all around ------------------------------------------------------------------------ r36937 | fijal | 2007-01-18 14:22:54 +0100 (Thu, 18 Jan 2007) | 2 lines Create a branch for further config cleanups. ------------------------------------------------------------------------ --HG-- branch : trunk --- py/doc/test_conftest.py.merge.tmp | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 py/doc/test_conftest.py.merge.tmp diff --git a/py/doc/test_conftest.py.merge.tmp b/py/doc/test_conftest.py.merge.tmp new file mode 100644 index 000000000..4c71bde92 --- /dev/null +++ b/py/doc/test_conftest.py.merge.tmp @@ -0,0 +1,73 @@ + +import py + +def setup_module(mod): + mod.tmpdir = py.test.ensuretemp('docdoctest') + +def test_doctest_basic(): + # XXX get rid of the next line: + py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py')) + + xtxt = tmpdir.join('x.txt') + xtxt.write(py.code.Source(""" + .. + >>> from os.path import abspath + + hello world + + >>> assert abspath + >>> i=3 + >>> print i + 3 + + yes yes + + >>> i + 3 + + end + """)) + config = py.test.config._reparse([xtxt]) + session = config.initsession() + session.main() + l = session.getitemoutcomepairs(py.test.Item.Failed) + assert len(l) == 0 + l = session.getitemoutcomepairs(py.test.Item.Passed) + l2 = session.getitemoutcomepairs(py.test.Item.Skipped) + assert len(l+l2) == 2 + +def test_js_ignore(): + py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py')) + tmpdir.ensure('__init__.py') + xtxt = tmpdir.join('x.txt') + xtxt.write(py.code.Source(""" + `blah`_ + + .. _`blah`: javascript:some_function() + """)) + config = py.test.config._reparse([xtxt]) + session = config.initsession() + session.main() + l = session.getitemoutcomepairs(py.test.Item.Failed) + assert len(l) == 0 + l = session.getitemoutcomepairs(py.test.Item.Passed) + l2 = session.getitemoutcomepairs(py.test.Item.Skipped) + assert len(l+l2) == 3 + +def test_resolve_linkrole(): + from py.__.doc.conftest import resolve_linkrole + assert resolve_linkrole('api', 'py.foo.bar') == ( + 'py.foo.bar', '../../apigen/api/foo.bar.html') + assert resolve_linkrole('api', 'py.foo.bar()') == ( + 'py.foo.bar()', '../../apigen/api/foo.bar.html') + assert resolve_linkrole('api', 'py') == ( + 'py', '../../apigen/api/index.html') + py.test.raises(AssertionError, 'resolve_linkrole("api", "foo.bar")') + assert resolve_linkrole('source', 'py/foo/bar.py') == ( + 'py/foo/bar.py', '../../apigen/source/foo/bar.py.html') + assert resolve_linkrole('source', 'py/foo/') == ( + 'py/foo/', '../../apigen/source/foo/index.html') + assert resolve_linkrole('source', 'py/') == ( + 'py/', '../../apigen/source/index.html') + py.test.raises(AssertionError, 'resolve_linkrole("source", "/foo/bar/")') +