[svn r45646] Rewrite it a bit not to rely on exact formatting (rather checking whether

information is there)

--HG--
branch : trunk
This commit is contained in:
fijal 2007-08-14 11:45:04 +02:00
parent 8ce22f32ac
commit 5318f7b145
2 changed files with 19 additions and 28 deletions

View File

@ -18,7 +18,6 @@ etc.
import py, os import py, os
#py.test.skip("in progress")
from py.__.test.rsession.rsession import LocalReporter, AbstractSession,\ from py.__.test.rsession.rsession import LocalReporter, AbstractSession,\
RemoteReporter RemoteReporter
from py.__.test.rsession import repevent from py.__.test.rsession import repevent
@ -173,23 +172,19 @@ class TestLocalReporter(AbstractTestReporter):
reporter = LocalReporter reporter = LocalReporter
def test_report_received_item_outcome(self): def test_report_received_item_outcome(self):
#py.test.skip("XXX rewrite test to not rely on exact formatting")
assert self.report_received_item_outcome() == 'FsF.' assert self.report_received_item_outcome() == 'FsF.'
def test_module(self): def test_module(self):
#py.test.skip("XXX rewrite test to not rely on exact formatting")
output = self._test_module() output = self._test_module()
assert output.find("test_one") != -1 assert output.find("test_one") != -1
assert output.endswith("FsF."), output assert output.endswith("FsF."), output
def test_full_module(self): def test_full_module(self):
#py.test.skip("XXX rewrite test to not rely on exact formatting")
received = self._test_full_module() received = self._test_full_module()
expected = """ expected_lst = ["repmod/test_one.py", "FAILED TO LOAD MODULE",
repmod/test_one.py[1] "skipped", "reason"]
repmod/test_three.py[0] - FAILED TO LOAD MODULE for i in expected_lst:
repmod/test_two.py[0] - skipped (reason)""" assert received.find(i) != -1
assert received.find(expected) != -1
class TestRemoteReporter(AbstractTestReporter): class TestRemoteReporter(AbstractTestReporter):
reporter = RemoteReporter reporter = RemoteReporter
@ -198,28 +193,24 @@ class TestRemoteReporter(AbstractTestReporter):
self._test_still_to_go() self._test_still_to_go()
def test_report_received_item_outcome(self): def test_report_received_item_outcome(self):
py.test.skip("XXX rewrite test to not rely on exact formatting")
val = self.report_received_item_outcome() val = self.report_received_item_outcome()
expected = """ localhost: FAILED py.test.rsession.testing.test_slave.py funcpass expected_lst = ["localhost", "FAILED",
localhost: SKIPPED py.test.rsession.testing.test_slave.py funcpass "funcpass", "test_one",
localhost: FAILED py.test.rsession.testing.test_slave.py funcpass "SKIPPED",
localhost: PASSED py.test.rsession.testing.test_slave.py funcpass "PASSED"]
""" for expected in expected_lst:
assert val.find(expected) != -1 assert val.find(expected) != -1
def test_module(self): def test_module(self):
py.test.skip("XXX rewrite test to not rely on exact formatting")
val = self._test_module() val = self._test_module()
print val expected_lst = ["localhost", "FAILED",
expected = """ localhost: FAILED py.test.rsession.testing.test_slave.py funcpass "funcpass", "test_one",
localhost: SKIPPED py.test.rsession.testing.test_slave.py funcpass "SKIPPED",
localhost: FAILED py.test.rsession.testing.test_slave.py funcpass "PASSED"]
localhost: PASSED py.test.rsession.testing.test_slave.py funcpass for expected in expected_lst:
"""
assert val.find(expected) != -1 assert val.find(expected) != -1
def test_full_module(self): def test_full_module(self):
#py.test.skip("XXX rewrite test to not rely on exact formatting")
val = self._test_full_module() val = self._test_full_module()
assert val.find('FAILED TO LOAD MODULE: repmod/test_three.py\n'\ assert val.find("FAILED TO LOAD MODULE: repmod/test_three.py\n"\
'\nSkipped (reason) repmod/test_two.py') != -1 "\nSkipped ('reason') repmod/test_two.py") != -1

View File

@ -29,7 +29,7 @@ def test_example_tryiter():
rootcol = py.test.collect.Directory(tmpdir) rootcol = py.test.collect.Directory(tmpdir)
data = list(rootcol._tryiter(reporterror=events.append)) data = list(rootcol._tryiter(reporterror=events.append))
assert len(events) == 2 assert len(events) == 2
assert str(events[1][0].value) == "Reason" assert str(events[1][0].value).find("Reason") != -1
class TestRSessionRemote(DirSetup, BasicRsessionTest): class TestRSessionRemote(DirSetup, BasicRsessionTest):
def test_example_distribution_minus_x(self): def test_example_distribution_minus_x(self):