[py-svn] r35158 - in py/dist/py/test/rsession: . testing
guido at codespeak.net
guido at codespeak.net
Thu Nov 30 15:00:34 CET 2006
Author: guido
Date: Thu Nov 30 15:00:30 2006
New Revision: 35158
Modified:
py/dist/py/test/rsession/testing/test_webjs.py
py/dist/py/test/rsession/webjs.py
Log:
Fixed unit test, removed bare except that hid the bug, fixed HTML bug where a
table was a direct child of a table row (not allowed), whitespace fixes.
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 Thu Nov 30 15:00:30 2006
@@ -60,8 +60,8 @@
assert len(tr.childNodes) == 2
assert tr.childNodes[0].nodeName == 'TD'
assert tr.childNodes[0].innerHTML == 'foo.py[0/10]'
- # XXX this is bad I think! table should be inside td
- assert tr.childNodes[1].nodeName == 'TABLE'
+ assert tr.childNodes[1].nodeName == 'TD'
+ assert tr.childNodes[1].childNodes[0].nodeName == 'TABLE'
assert len(tr.childNodes[1].getElementsByTagName('tr')) == 0
def test_process_two():
@@ -77,11 +77,15 @@
'fullmodulename': 'modules/foo.py',
'passed' : 'True',
'fullitemname' : 'modules/foo.py/test_item',
+ 'hostkey': None,
}
webjs.process(msg)
+ print '<html>%s</html>' % (dom.get_document().documentElement.innerHTML,)
trs = main_t.getElementsByTagName('tr')
tds = trs[0].getElementsByTagName('td')
- assert len(tds) == 2
- # XXX: This assert obviously is true in output code, why it does not work?
- assert tds[0].innerHTML == 'foo.py[1/10]'
- assert tds[1].innerHTML == '.'
+ # two cells in the row, one in the table inside one of the cells
+ assert len(tds) == 3
+ html = tds[0].innerHTML
+ assert html == 'foo.py[1/10]'
+ assert tds[2].innerHTML == '.'
+
Modified: py/dist/py/test/rsession/webjs.py
==============================================================================
--- py/dist/py/test/rsession/webjs.py (original)
+++ py/dist/py/test/rsession/webjs.py Thu Nov 30 15:00:30 2006
@@ -79,13 +79,17 @@
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("onmouseover",
+ "show_info('%s')" % (msg['fullitemname'],))
td.setAttribute("onmouseout", "hide_info()")
+ td2 = create_elem('td')
+ tr.appendChild(td2)
table = create_elem("table")
- tr.appendChild(table)
- table.id = msg['fullitemname']
+ td2.appendChild(table)
+ tbody = create_elem('tbody')
+ tbody.id = msg['fullitemname']
+ table.appendChild(tbody)
counters[msg['fullitemname']] = 0
main_t.appendChild(tr)
@@ -93,68 +97,65 @@
host_elem = dom.get_document().getElementById(msg['hostkey'])
glob.host_pending[msg['hostkey']].insert(0, msg['fullitemname'])
count = len(glob.host_pending[msg['hostkey']])
- host_elem.childNodes[0].nodeValue = glob.host_dict[msg['hostkey']] + '[' +\
- str(count) + ']'
+ host_elem.childNodes[0].nodeValue = '%s[%s]' % (
+ glob.host_dict[msg['hostkey']], count)
elif msg['type'] == 'HostReady':
host_elem = dom.get_document().getElementById(msg['hostkey'])
host_elem.style.background = \
"#00ff00"
- host_elem.childNodes[0].nodeValue = glob.host_dict[msg['hostkey']] + '[0]'
+ host_elem.childNodes[0].nodeValue = '%s[0]' % (
+ glob.host_dict[msg['hostkey']],)
elif msg['type'] == 'ReceivedItemOutcome':
- try:
- module_part = get_elem(msg['fullmodulename'])
- if not module_part:
- 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 = glob.host_dict[msg['hostkey']] + '[' +\
- str(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)
- counter_part.childNodes[0].nodeValue = "%s[%d/%d]" % (
- short_item_names[name], counters[name], max_items[name])
- module_part.childNodes[-1].appendChild(td)
-
- except:
- dom.get_document().getElementById("testmain").innerHTML += \
- "some error"
+ module_part = get_elem(msg['fullmodulename'])
+ if not module_part:
+ 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)
elif msg['type'] == 'TestFinished':
dom.get_document().title = "Py.test [FINISHED]"
dom.get_document().getElementById("Tests").childNodes[0].nodeValue = \
@@ -202,7 +203,8 @@
set_msgbox(item_name, data)
def fail_come_back(msg):
- tracebacks[msg['item_name']] = (msg['traceback'], msg['stdout'], msg['stderr'])
+ tracebacks[msg['item_name']] = (msg['traceback'], msg['stdout'],
+ msg['stderr'])
def skip_come_back(msg):
skips[msg['item_name']] = msg['reason']
More information about the pytest-commit
mailing list