Revision: 3d9b7cbb5a78
Author:   Pekka Klärck
Date:     Mon Aug 27 06:09:54 2012
Log:      Fixed unittest on IronPython

Update issue 1207
Status: Review
Labels: Type-Task, Target-2.7.4
Thanks for the report. I was able to reproduce this also on WinXP. I decided
to fix the problm slightly differently than in the provided patch. Fix was
done on Linux and is yet to be actually tested with IronPython.
http://code.google.com/p/robotframework/source/detail?r=3d9b7cbb5a78

Modified:
 /utest/api/test_run_and_rebot.py

=======================================
--- /utest/api/test_run_and_rebot.py    Sat Jun 30 16:02:25 2012
+++ /utest/api/test_run_and_rebot.py    Mon Aug 27 06:09:54 2012
@@ -69,9 +69,15 @@

     def _assert_output_contains(self, output, expected):
         for content, count in expected:
-            if output.count(content) != count:
-                raise AssertionError("'%s' not %d times in output:\n%s"
-                                     % (content, count, output))
+            if isinstance(count, tuple):
+                minimum, maximum = count
+                error = '%d-%d' % count
+            else:
+                minimum = maximum = count
+                error = '%d' % count
+            if not (minimum <= output.count(content) <= maximum):
+                raise AssertionError("'%s' not %s times in output:\n%s"
+                                     % (content, error, output))


 class TestRun(Base):
@@ -92,8 +98,11 @@
     def test_run_fails(self):
         assert_equals(run(self.nonex), 252)
         assert_equals(run(self.data, outputdir=TEMP), 1)
+ # self.nonex always appears in our error message. It may also appear
+        # in the error message by the interpreter included in our message.
         self._assert_outputs(stdout=[('Pass And Fail', 2), (LOG, 1)],
- stderr=[('[ ERROR ]', 1), (self.nonex, 1), ('--help', 1)]) + stderr=[('[ ERROR ]', 1), (self.nonex, (1, 2)),
+                                     ('--help', 1)])

     def test_custom_stdout(self):
         stdout = StringIO()

Reply via email to