Revision: 9a61ae049560
Branch:   default
Author:   Pekka Klärck
Date:     Mon Sep 17 05:46:37 2012
Log: ooops, changing the logic of --RemoveKeywords FOR affected some other tests...
http://code.google.com/p/robotframework/source/detail?r=9a61ae049560

Modified:
 /atest/robot/cli/rebot/remove_keywords/combinations.txt
 /atest/testdata/cli/remove_keywords/all_combinations.txt
 /utest/result/test_configurer.py

=======================================
--- /atest/robot/cli/rebot/remove_keywords/combinations.txt Wed Sep 12 16:05:24 2012 +++ /atest/robot/cli/rebot/remove_keywords/combinations.txt Mon Sep 17 05:46:37 2012
@@ -23,12 +23,18 @@
${rmkws}= Catenate SEPARATOR= --RemoveKeywords= ${EMPTY} @{options}
     Run Rebot    ${rmkws} --log log.html   ${INPUTFILE}
     Validate Log    @{options}
+    Validate Tests

 Validate Log
     [Arguments]    @{options}
-    ${LOG}=   Get File  ${OUTDIR}/log.html
-    : FOR   ${item}  in  @{options}
-    \   Should Not Contain  ${LOG}  -${item}
+    ${LOG}=    Get File    ${OUTDIR}/log.html
+    : FOR    ${item}    IN    @{options}
+    \   Should Not Contain    ${LOG}    -${item}
+
+Validate Tests
+    Check Suite Contains Tests    ${SUITE}    Passing    Failing
+    ...    For when test fails    For when test passes
+    ...    WUKS when test fails    WUKS when test passes

 Create Output
Create Output With Robot ${INPUTFILE} ${EMPTY} cli/remove_keywords/all_combinations.txt
=======================================
--- /atest/testdata/cli/remove_keywords/all_combinations.txt Wed Sep 12 16:05:24 2012 +++ /atest/testdata/cli/remove_keywords/all_combinations.txt Mon Sep 17 05:46:37 2012
@@ -2,7 +2,8 @@
 ${COUNTER}         ${0}
 ${PASS MESSAGE}    -PASSED -ALL
 ${FAIL MESSAGE}    -ALL +PASSED
-${FOR MESSAGE}     -FOR -ALL
+${REMOVED FOR MESSAGE}     -FOR -ALL
+${KEPT FOR MESSAGE}        +FOR -ALL
 ${REMOVED WUKS MESSAGE}    -WUKS -ALL
 ${KEPT WUKS MESSAGE}       +WUKS -ALL

@@ -19,25 +20,30 @@

 For when test fails
     [Documentation]    FAIL Cannot pass
-    :FOR    ${num}    IN    one    two    three
-    \    Log    ${FOR MESSAGE} ${num}
+    My FOR
     Fail    Cannot pass

 For when test passes
-    :FOR    ${num}    IN    one    two    three
-    \    Log    ${FOR MESSAGE} ${num}
+    My FOR

 WUKS when test fails
     [Documentation]    FAIL Cannot pass
-    Wait Until Keyword Succeeds    2s    0.01s    My Keyword
+    Wait Until Keyword Succeeds    2s    0.01s    My WUKS
     Fail    Cannot pass

 WUKS when test passes
-     Wait Until Keyword Succeeds    2s    0.01s    My Keyword
+     Wait Until Keyword Succeeds    2s    0.01s    My WUKS

 *** Keywords ***

-My Keyword
+My FOR
+    :FOR    ${item}    IN    one    two    three    LAST
+    \    Run Keyword If    "${item}" == "LAST"
+    \    ...    Log    ${KEPT FOR MESSAGE} ${item}
+    \    ...    ELSE
+    \    ...    Log    ${REMOVED FOR MESSAGE} ${item}
+
+My WUKS
     Set Test Variable    $COUNTER    ${COUNTER + 1}
     Run Keyword If    ${COUNTER} < 10    Fail    ${REMOVED WUKS MESSAGE}
     Run Keyword If    ${COUNTER} == 10    Fail    ${KEPT WUKS MESSAGE}
=======================================
--- /utest/result/test_configurer.py    Mon Mar  5 05:32:49 2012
+++ /utest/result/test_configurer.py    Mon Sep 17 05:46:37 2012
@@ -1,6 +1,6 @@
 from itertools import chain
 import unittest
-from robot.utils.asserts import assert_equal, assert_raises_with_msg
+from robot.utils.asserts import assert_equal, assert_raises_with_msg, assert_true

 from robot.errors import DataError
 from robot.result.testsuite import TestSuite
@@ -180,10 +180,12 @@
         assert_equal(len(suite.keywords.setup.messages), 1)
         assert_equal(len(suite.keywords.teardown.keywords), 1)

-    def test_remove_for_removes_for_loop_items_when_item_is_passed(self):
+    def test_remove_for_removes_passed_items_except_last(self):
         suite, forloop = self.suite_with_forloop()
+        last = forloop.keywords[-1]
         self._remove_for_loop(suite)
-        assert_equal(len(forloop.keywords), 0)
+        assert_equal(len(forloop.keywords), 1)
+        assert_true(forloop.keywords[-1] is last)

     def suite_with_forloop(self):
         suite = TestSuite()
@@ -197,16 +199,19 @@

def test_remove_for_removes_passing_items_when_there_are_failures(self):
         suite, forloop = self.suite_with_forloop()
-        suite.tests[0].keywords.create(status='FAIL')
-        suite.tests[0].status = 'FAIL'
+        failed = forloop.keywords.create(status='FAIL')
         self._remove_for_loop(suite)
-        assert_equal(len(forloop.keywords), 0)
+        assert_equal(len(forloop.keywords), 1)
+        assert_true(forloop.keywords[-1] is failed)

     def test_remove_for_does_not_remove_for_loop_items_with_warnings(self):
         suite, forloop = self.suite_with_forloop()
forloop.keywords[2].messages.create(message='danger!', level='WARN')
+        warn = forloop.keywords[2]
+        last = forloop.keywords[-1]
         self._remove_for_loop(suite)
-        assert_equal(len(forloop.keywords), 1)
+        assert_equal(len(forloop.keywords), 2)
+        assert_equal(list(forloop.keywords), [warn, last])

     def test_remove_based_on_multiple_condition(self):
         suite = TestSuite()
@@ -214,11 +219,13 @@
         t1.keywords.create().messages.create()
         t2 = suite.tests.create(status='FAIL')
         t2.keywords.create().messages.create()
- t2.keywords.create(type='for').keywords.create(type='foritem', status='PASS')
+        t2.keywords.create(type='for')
+        for i in range(10):
+            t2.keywords[1].keywords.create(type='foritem', status='PASS')
         self._remove(['passed', 'for'], suite)
-        assert_equal(len(suite.tests[0].keywords[0].messages), 0)
-        assert_equal(len(suite.tests[1].keywords[0].messages), 1)
-        assert_equal(len(suite.tests[1].keywords[1].keywords), 0)
+        assert_equal(len(t1.keywords[0].messages), 0)
+        assert_equal(len(t2.keywords[0].messages), 1)
+        assert_equal(len(t2.keywords[1].keywords), 1)

     def _suite_with_setup_and_teardown_and_test_with_keywords(self):
         suite = TestSuite()

Reply via email to