[py-svn] r36683 - py/dist/py/apigen/testing
guido at codespeak.net
guido at codespeak.net
Sat Jan 13 18:27:38 CET 2007
Author: guido
Date: Sat Jan 13 18:27:37 2007
New Revision: 36683
Added:
py/dist/py/apigen/testing/test_apigen_functional.py
Modified:
py/dist/py/apigen/testing/test_apigen_example.py
Log:
Made test_apigen_example.setup_fs_project() get the name of the temp dir as an
argument so it can more easily be used from other tests, added simple
functional test for 'py.test --apigen', some whitespace issues.
Modified: py/dist/py/apigen/testing/test_apigen_example.py
==============================================================================
--- py/dist/py/apigen/testing/test_apigen_example.py (original)
+++ py/dist/py/apigen/testing/test_apigen_example.py Sat Jan 13 18:27:37 2007
@@ -7,8 +7,8 @@
from py.__.test.web import webcheck
from py.__.apigen.conftest import option
-def setup_fs_project():
- temp = py.test.ensuretemp('apigen_example')
+def setup_fs_project(tempname='apigen_example'):
+ temp = py.test.ensuretemp(tempname)
temp.ensure("pkg/func.py").write(py.code.Source("""\
def func(arg1):
"docstring"
@@ -48,9 +48,8 @@
dsa = DocStorageAccessor(ds)
return dsa
-
def _checkhtml(htmlstring):
- assert isinstance(htmlstring, (unicode, str))
+ assert isinstance(htmlstring, (unicode, str))
if option.webcheck:
webcheck.check_html(htmlstring)
else:
Added: py/dist/py/apigen/testing/test_apigen_functional.py
==============================================================================
--- (empty file)
+++ py/dist/py/apigen/testing/test_apigen_functional.py Sat Jan 13 18:27:37 2007
@@ -0,0 +1,45 @@
+""" functional test for apigen.py
+
+ script to build api + source docs from py.test
+"""
+
+import py
+from test_apigen_example import setup_fs_project
+
+class TestApigenFunctional(object):
+ def setup_class(cls):
+ cls.fs_root, cls.package_name = setup_fs_project(
+ 'test_apigen_functional')
+
+ def test_apigen(self):
+ tempdir = py.test.ensuretemp('test_apigen_functional_results')
+ parentdir = py.magic.autopath().dirpath().dirpath()
+ pkgdir = self.fs_root.join('pkg')
+ output = py.process.cmdexec(
+ 'APIGEN_TARGET=%s py.test --session=L --apigen=%s/apigen.py %s' % (
+ tempdir, parentdir, pkgdir))
+ assert output.endswith('=======\n') # no traceback in the end
+
+ # just some quick content checks
+ apidir = tempdir.join('api')
+ assert apidir.check(dir=True)
+ someclass_api = apidir.join('pkg.SomeClass.html')
+ assert someclass_api.check(file=True)
+ assert someclass_api.read().find(
+ '<a href="api/pkg.SomeClass.html">SomeClass</a>') > -1
+ someclass_init_api = apidir.join('pkg.SomeClass.__init__.html')
+ assert someclass_init_api.check(file=True)
+ assert someclass_init_api.read().find(
+ '<a href="api/pkg.SomeClass.__init__.html">__init__</a>') > -1
+
+ sourcedir = tempdir.join('source')
+ assert sourcedir.check(dir=True)
+ someclass_source = sourcedir.join('someclass.py.html')
+ assert someclass_source.check(file=True)
+ assert someclass_source.read().find(
+ '<div class="project_title">sources for someclass.py</div>') > -1
+
+ # XXX later...
+ #index = sourcedir.join('index.html')
+ #assert index.check(file=True)
+
More information about the pytest-commit
mailing list