[pytest-dev] Question on item result
Ayelet Regev
ayelet at fabrixsystems.com
Wed Sep 17 16:50:27 CEST 2014
i am using this hook...
i have 1 test with 2 configurations provided using item._request.cfg
then when im running the tests using xdist, i see that
"slaveoutput["exitstatus"] is aware of the failure. but report.outcome
climing both have "passed"
def test_cm_delete(request):
cfg = request.cfg
if cfg.get("channel_name") == "working_20":
assert True
else:
assert False
def pytest_runtest_makereport(__multicall__, item, call):
report = __multicall__.execute()
if call.when == "teardown" :
try:
*item.config.logger.info2("item %s with cfg %s - Report OUTCOME : %s" %
(item.name,item._request.cfg,report.outcome))*
except:
pass
return report
def pytest_testnodedown(node, error):
*node.config.logger.info2("slaveoutput of node %s" % (node.slaveoutput))*
log:
[2014-09-17 17:44:56,209][MainThread] Run-test: test_cm_delete -
[{'comment': u'ChannelMapname', 'name': u'channel_name', 'defaultvalue':
u'bbbbbb', 'value': u'working_21', 'choices':
u'functionnametosendtoknownURLwithargsofactivityandfuncname', 'type':
u'string'}]
[2014-09-17 17:44:56,217][MainThread] Teardown: test_cm_delete -
[{'comment': u'ChannelMapname', 'name': u'channel_name', 'defaultvalue':
u'bbbbbb', 'value': u'working_21', 'choices':
u'functionnametosendtoknownURLwithargsofactivityandfuncname', 'type':
u'string'}]
[2014-09-17 17:44:56,218][MainThread] *item test_cm_delete with cfg
{u'channel_name': u'working_21'} - Report OUTCOME : passed*
[2014-09-17 17:44:56,225][MainThread] *slaveoutput of node
{'exitstatus': 1}*
[2014-09-17 17:45:00,218][MainThread] Run-test: test_cm_delete -
[{'comment': u'ChannelMapname', 'name': u'channel_name', 'defaultvalue':
u'aaaaaaaaaaaaa', 'value': u'working_20', 'choices': u'functionname to
send to known URL with args of activity and funcname', 'type': u'string'}]
[2014-09-17 17:45:00,219][MainThread] Teardown: test_cm_delete -
[{'comment': u'ChannelMapname', 'name': u'channel_name', 'defaultvalue':
u'aaaaaaaaaaaaa', 'value': u'working_20', 'choices': u'functionname to
send to known URL with args of activity and funcname', 'type': u'string'}]
[2014-09-17 17:45:00,220][MainThread] *item test_cm_delete with cfg
{u'channel_name': u'working_20'} - Report OUTCOME : passed*
[2014-09-17 17:45:00,226][MainThread]*slaveoutput of node {'exitstatus': 0}*
console output:
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1 --
/usr/bin/python
plugins: xdist, timeout, cov
[gw0] linux2 Python 2.7.6 cwd:
/home/ayelet/Scripts/sysu/root/var/sysu/cache/Activities
[gw1] linux2 Python 2.7.6 cwd:
/home/ayelet/Scripts/sysu/root/var/sysu/cache/Activities
[gw0] Python 2.7.6 (default, Mar 22 2014, 22:59:56) -- [GCC 4.8.2]
[gw1] Python 2.7.6 (default, Mar 22 2014, 22:59:56) -- [GCC 4.8.2]
gw0 [2] / gw1 [2]
scheduling tests via LoadScheduling
Ingest/ChannelMap/delete_cm/test_delete_cm.py::test_cm_delete
*[gw0] FAILED
Ingest/ChannelMap/delete_cm/test_delete_cm.py::test_cm_delete **
**[gw1] PASSED
Ingest/ChannelMap/delete_cm/test_delete_cm.py::test_cm_delete *
============================================================================
FAILURES
=============================================================================
_________________________________________________________________________ test_cm_delete
__________________________________________________________________________
[gw0] linux2 -- Python 2.7.6 /usr/bin/python
request = <FixtureRequest for <Function 'test_cm_delete'>>
def test_cm_delete(request):
cfg = request.cfg
servers_data = request.config.properties["Servers"]
#request.config.logger.info2("AYELET WAS HERE %s" % (cfg))
request.basa = "BASA"
#assert delete_cm(cfg,servers_data) == 200
if cfg.get("channel_name") == "working_20":
assert True
else:
> assert False
E assert False
Ingest/ChannelMap/delete_cm/test_delete_cm.py:22: AssertionError
*=============================================================== 1
failed, 1 passed in 6.23 seconds
================================================================*
On 17/09/14 17:28, Holger Krekel wrote:
> You might adapt this example:
> http://pytest.org/latest/example/simple.html#making-test-result-information-available-in-fixtures
>
> On September 17, 2014 3:18:05 PM CEST, Ayelet Regev
> <ayelet at fabrixsystems.com> wrote:
>
> Hi,
>
> I want to be able to get the result from each item at teardown.
> What should i look for?
>
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
Best Regards,
Ayelet Regev Dabah
Email: ayelet at fabrixsystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20140917/6033f99f/attachment.html>
More information about the Pytest-dev
mailing list