[pypy-svn] r55051 - pypy/django/tests

hpk at codespeak.net hpk at codespeak.net
Wed May 21 11:47:22 CEST 2008


Author: hpk
Date: Wed May 21 11:47:20 2008
New Revision: 55051

Modified:
   pypy/django/tests/conftest.py
Log:
(anto,hpk) run the correct doctests


Modified: pypy/django/tests/conftest.py
==============================================================================
--- pypy/django/tests/conftest.py	(original)
+++ pypy/django/tests/conftest.py	Wed May 21 11:47:20 2008
@@ -23,6 +23,7 @@
 class DocTestItem(py.test.collect.Item):
 
     def __init__(self, name, mod, docstr):
+        assert docstr is not None
         py.test.collect.Item.__init__(self, name)
         self.docstr = docstr
         self.mod = mod
@@ -47,6 +48,7 @@
         runner = DocTestRunner(checker=checker)
         parser = _doctest.DocTestParser()
         globs = mod.__dict__.copy()
+        assert docstring is not None
         test = parser.get_doctest(docstring, globs, "foo", "foobar", 0)
         runner.run(test)
         if runner.failures: 
@@ -94,10 +96,10 @@
 
     def _find_doctests(self, mod):
         if hasattr(mod, '__test__'):
-            return ["__test__[%s]" % x for x in mod.__test__.keys()]
+            return ["__test__[%s]" % x for x in mod.__test__.keys() 
+                      if mod.__test__[x]]
         if os.path.basename(mod.__file__).startswith("tests") and mod.__doc__:
             return ['%docmodulestring%']
-            #return [)]
         return []
 
     def _get_mod(self):
@@ -121,7 +123,9 @@
         mod = self._get_mod()
         if name.startswith("__test__["):
             doctestname = name[9:-1] 
-            return DocTestItem(name, mod, mod.__test__[doctestname])
+            docstring = mod.__test__[doctestname]
+            assert docstring is not None
+            return DocTestItem(name, mod, docstring)
         elif name.startswith('tests.__test__['):
             doctestname = name[15:-1] 
             mod = mod.tests
@@ -129,7 +133,7 @@
         elif name == '%docmodulestring%':
             return DocTestItem(self.fspath.basename + '.%docstring%', mod, mod.__doc__)
         elif name == 'tests.%docmodulestring%':
-            return DocTestItem(self.fspath.basename + '.test.%docstring%', mod, mod.__doc__)
+            return DocTestItem(self.fspath.basename + '.tests.%docstring%', mod.tests, mod.tests.__doc__)
         elif name.startswith('tests'):
             return DjangoUnitTest(name, self) 
         else:
@@ -160,8 +164,6 @@
             mod = getattr(mod, "tests") 
         else:
             assert len(names) == 2
-        #import pdb 
-        #pdb.set_trace()
         testcasecls = getattr(mod, names[0])
         testcase = testcasecls(names[1])
         run_testcase_method(testcase) 



More information about the Pypy-commit mailing list