[py-svn] r34451 - in py/dist/py/test/rsession: . testing webdata
guido at codespeak.net
guido at codespeak.net
Fri Nov 10 11:33:37 CET 2006
Author: guido
Date: Fri Nov 10 11:33:34 2006
New Revision: 34451
Added:
py/dist/py/test/rsession/testing/test_webjs.py
Modified:
py/dist/py/test/rsession/webdata/index.html
py/dist/py/test/rsession/webdata/source.js
py/dist/py/test/rsession/webjs.py
Log:
Added first tests for code that is translated to JS (using the mock DOM API
from PyPy), added missing </script> end tag in index.html.
Added: py/dist/py/test/rsession/testing/test_webjs.py
==============================================================================
--- (empty file)
+++ py/dist/py/test/rsession/testing/test_webjs.py Fri Nov 10 11:33:34 2006
@@ -0,0 +1,28 @@
+import py
+try:
+ import pypy
+except ImportError:
+ py.test.skip('missing PyPy')
+from pypy.translator.js.modules import dom
+from py.__.test.rsession import webjs
+
+here = py.magic.autopath().dirpath()
+
+def setup_module(mod):
+ # load HTML into window object
+ html = here.join('../webdata/index.html').read()
+ dom.window = dom.Window(html)
+
+def test_html_loaded():
+ body = dom.window.document.getElementsByTagName('body')[0]
+ assert len(body.childNodes) > 0
+ assert str(body.childNodes[1].nodeName) == 'A'
+
+def test_set_msgbox():
+ msgbox = dom.window.document.getElementById('messagebox')
+ assert len(msgbox.childNodes) == 0
+ webjs.set_msgbox('foo', 'bar')
+ assert len(msgbox.childNodes) == 1
+ assert msgbox.childNodes[0].nodeName == 'PRE'
+ assert msgbox.childNodes[0].childNodes[0].nodeValue == 'foo\nbar'
+
Modified: py/dist/py/test/rsession/webdata/index.html
==============================================================================
--- py/dist/py/test/rsession/webdata/index.html (original)
+++ py/dist/py/test/rsession/webdata/index.html Fri Nov 10 11:33:34 2006
@@ -2,6 +2,7 @@
<head>
<title>Py.test</title>
<script type="text/javascript" src="/jssource">
+ </script>
</head>
<body onload="main()">
<a name="beginning">
Modified: py/dist/py/test/rsession/webdata/source.js
==============================================================================
Binary files. No diff available.
Modified: py/dist/py/test/rsession/webjs.py
==============================================================================
--- py/dist/py/test/rsession/webjs.py (original)
+++ py/dist/py/test/rsession/webjs.py Fri Nov 10 11:33:34 2006
@@ -5,7 +5,7 @@
import py
from py.__.test.rsession.web import exported_methods
try:
- from pypy.translator.js.modules import _dom as dom
+ from pypy.translator.js.modules import dom
from pypy.translator.js.helper import __show_traceback
from pypy.translator.transformer.debug import traceback_handler
except ImportError:
More information about the pytest-commit
mailing list