[py-svn] r35344 - in py/dist/py/test/rsession: . testing webdata
fijal at codespeak.net
fijal at codespeak.net
Tue Dec 5 22:42:12 CET 2006
Author: fijal
Date: Tue Dec 5 22:42:06 2006
New Revision: 35344
Modified:
py/dist/py/test/rsession/testing/test_webjs.py
py/dist/py/test/rsession/web.py
py/dist/py/test/rsession/webdata/source.js
py/dist/py/test/rsession/webjs.py
Log:
A bit of fixes and refactoring. Broken tests though :-(
Modified: py/dist/py/test/rsession/testing/test_webjs.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_webjs.py (original)
+++ py/dist/py/test/rsession/testing/test_webjs.py Tue Dec 5 22:42:06 2006
@@ -4,7 +4,7 @@
except ImportError:
py.test.skip('missing PyPy')
-
+from pypy.translator.js.tester import schedule_callbacks
here = py.magic.autopath().dirpath()
def setup_module(mod):
@@ -18,7 +18,9 @@
session_options.bind_config(config)
session_options.import_pypy = True
from py.__.test.rsession import webjs
+ from py.__.test.rsession.web import exported_methods
mod.webjs = webjs
+ mod.exported_methods = exported_methods
def test_html_loaded():
body = dom.window.document.getElementsByTagName('body')[0]
@@ -96,3 +98,25 @@
assert html == 'foo.py[1/10]'
assert tds[2].innerHTML == '.'
+def test_signal():
+ main_t = dom.window.document.getElementById('main_table')
+ msg = {'type': 'ItemStart',
+ 'itemtype': 'Module',
+ 'itemname': 'foo.py',
+ 'fullitemname': 'modules/foo.py',
+ 'length': 10,
+ }
+ webjs.process(msg)
+ msg = {'type': 'ReceivedItemOutcome',
+ 'fullmodulename': 'modules/foo.py',
+ 'passed' : 'False',
+ 'fullitemname' : 'modules/foo.py/test_item',
+ 'hostkey': None,
+ 'signal': '10',
+ 'skipped': 'False',
+ }
+ webjs.process(msg)
+ print '<html>%s</html>' % (dom.get_document().documentElement.innerHTML,)
+ schedule_callbacks(exported_methods)
+ import pdb;pdb.set_trace()
+ assert main_t.getElementById('modules/foo.py')
Modified: py/dist/py/test/rsession/web.py
==============================================================================
--- py/dist/py/test/rsession/web.py (original)
+++ py/dist/py/test/rsession/web.py Tue Dec 5 22:42:06 2006
@@ -229,6 +229,10 @@
event.item, outcome.excinfo, outcome.excinfo.traceback)
self.stdout[fullitemname] = outcome.stdout
self.stderr[fullitemname] = outcome.stderr
+ elif outcome.signal:
+ self.fail_reasons[fullitemname] = "Received signal %d" % outcome.signal
+ self.stdout[fullitemname] = outcome.stdout
+ self.stderr[fullitemname] = outcome.stderr
if event.channel:
args['hostkey'] = event.channel.gateway.hostid
else:
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 Tue Dec 5 22:42:06 2006
@@ -62,6 +62,76 @@
info = dom.get_document().getElementById("info")
info.style.visibility = "hidden"
+def make_module_box(msg):
+ tr = create_elem("tr")
+ td = create_elem("td")
+ tr.appendChild(td)
+ td.appendChild(create_text_elem("%s[0/%s]" % (msg['itemname'],
+ msg['length'])))
+ max_items[msg['fullitemname']] = int(msg['length'])
+ short_item_names[msg['fullitemname']] = msg['itemname']
+ td.id = '_txt_' + msg['fullitemname']
+ #tr.setAttribute("id", msg['fullitemname'])
+ td.setAttribute("onmouseover",
+ "show_info('%s')" % (msg['fullitemname'],))
+ td.setAttribute("onmouseout", "hide_info()")
+
+ td2 = create_elem('td')
+ tr.appendChild(td2)
+ table = create_elem("table")
+ td2.appendChild(table)
+ tbody = create_elem('tbody')
+ tbody.id = msg['fullitemname']
+ table.appendChild(tbody)
+ counters[msg['fullitemname']] = 0
+ return tr
+
+def add_received_item_outcome(msg, module_part):
+ if msg['hostkey']:
+ host_elem = dom.get_document().getElementById(msg['hostkey'])
+ glob.host_pending[msg['hostkey']].pop()
+ count = len(glob.host_pending[msg['hostkey']])
+ host_elem.childNodes[0].nodeValue = '%s[%s]' % (
+ glob.host_dict[msg['hostkey']], count)
+
+ td = create_elem("td")
+ td.setAttribute("onmouseover", "show_info('%s')" % (
+ msg['fullitemname'],))
+ td.setAttribute("onmouseout", "hide_info()")
+ item_name = msg['fullitemname']
+ # TODO: dispatch output
+ if msg["passed"] == 'True':
+ txt = create_text_elem(".")
+ td.appendChild(txt)
+ elif msg["skipped"] != 'None' and msg["skipped"] != "False":
+ exported_methods.show_skip(item_name, skip_come_back)
+ link = create_elem("a")
+ link.setAttribute("href", "javascript:show_skip('%s')" % (
+ msg['fullitemname'],))
+ txt = create_text_elem('s')
+ link.appendChild(txt)
+ td.appendChild(link)
+ else:
+ link = create_elem("a")
+ link.setAttribute("href", "javascript:show_traceback('%s')" % (
+ msg['fullitemname'],))
+ txt = create_text_elem('F')
+ link.appendChild(txt)
+ td.appendChild(link)
+ exported_methods.show_fail(item_name, fail_come_back)
+
+ if counters[msg['fullmodulename']] % MAX_COUNTER == 0:
+ tr = create_elem("tr")
+ module_part.appendChild(tr)
+
+ name = msg['fullmodulename']
+ counters[name] += 1
+ counter_part = get_elem('_txt_' + name)
+ newcontent = "%s[%d/%d]" % (short_item_names[name], counters[name],
+ max_items[name])
+ counter_part.childNodes[0].nodeValue = newcontent
+ module_part.childNodes[-1].appendChild(td)
+
def process(msg):
if len(msg) == 0:
return False
@@ -71,28 +141,7 @@
if msg['type'] == 'ItemStart':
# we start a new directory or what
if msg['itemtype'] == 'Module':
- tr = create_elem("tr")
- td = create_elem("td")
- tr.appendChild(td)
- td.appendChild(create_text_elem("%s[0/%s]" % (msg['itemname'],
- msg['length'])))
- max_items[msg['fullitemname']] = int(msg['length'])
- short_item_names[msg['fullitemname']] = msg['itemname']
- td.id = '_txt_' + msg['fullitemname']
- #tr.setAttribute("id", msg['fullitemname'])
- td.setAttribute("onmouseover",
- "show_info('%s')" % (msg['fullitemname'],))
- td.setAttribute("onmouseout", "hide_info()")
-
- td2 = create_elem('td')
- tr.appendChild(td2)
- table = create_elem("table")
- td2.appendChild(table)
- tbody = create_elem('tbody')
- tbody.id = msg['fullitemname']
- table.appendChild(tbody)
- counters[msg['fullitemname']] = 0
-
+ tr = make_module_box(msg)
main_t.appendChild(tr)
elif msg['type'] == 'SendItem':
host_elem = dom.get_document().getElementById(msg['hostkey'])
@@ -113,50 +162,7 @@
glob.pending.append(msg)
return True
- if msg['hostkey']:
- host_elem = dom.get_document().getElementById(msg['hostkey'])
- glob.host_pending[msg['hostkey']].pop()
- count = len(glob.host_pending[msg['hostkey']])
- host_elem.childNodes[0].nodeValue = '%s[%s]' % (
- glob.host_dict[msg['hostkey']], count)
-
- td = create_elem("td")
- td.setAttribute("onmouseover", "show_info('%s')" % (
- msg['fullitemname'],))
- td.setAttribute("onmouseout", "hide_info()")
- item_name = msg['fullitemname']
- # TODO: dispatch output
- if msg["passed"] == 'True':
- txt = create_text_elem(".")
- td.appendChild(txt)
- elif msg["skipped"] != 'None':
- exported_methods.show_skip(item_name, skip_come_back)
- link = create_elem("a")
- link.setAttribute("href", "javascript:show_skip('%s')" % (
- msg['fullitemname'],))
- txt = create_text_elem('s')
- link.appendChild(txt)
- td.appendChild(link)
- else:
- link = create_elem("a")
- link.setAttribute("href", "javascript:show_traceback('%s')" % (
- msg['fullitemname'],))
- txt = create_text_elem('F')
- link.appendChild(txt)
- td.appendChild(link)
- exported_methods.show_fail(item_name, fail_come_back)
-
- if counters[msg['fullmodulename']] % MAX_COUNTER == 0:
- tr = create_elem("tr")
- module_part.appendChild(tr)
-
- name = msg['fullmodulename']
- counters[name] += 1
- counter_part = get_elem('_txt_' + name)
- newcontent = "%s[%d/%d]" % (short_item_names[name], counters[name],
- max_items[name])
- counter_part.childNodes[0].nodeValue = newcontent
- module_part.childNodes[-1].appendChild(td)
+ add_received_item_outcome(msg, module_part)
elif msg['type'] == 'TestFinished':
text = "FINISHED %s run, %s failures, %s skipped" % (msg['run'], msg['fails'], msg['skips'])
dom.get_document().title = "Py.test %s" % text
More information about the py-svn
mailing list