4 new revisions:

Revision: 27b31f9a14d7
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 04:39:22 2012
Log: screenshot tests: create log files and use debug level to ease debuggi...
http://code.google.com/p/robotframework/source/detail?r=27b31f9a14d7

Revision: 191a67b93720
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:03:30 2012
Log:      ETWrapper: Worked around IronPython inconsistence....
http://code.google.com/p/robotframework/source/detail?r=191a67b93720

Revision: d0a820da2197
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:40:13 2012
Log: ETSource: Cleaned up code dependent on different Python interpreters....
http://code.google.com/p/robotframework/source/detail?r=d0a820da2197

Revision: 5bec3b42e390
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:46:24 2012
Log: ET/XML library: Cleaned up XML parsing logic dependent on ET versions....
http://code.google.com/p/robotframework/source/detail?r=5bec3b42e390

==============================================================================
Revision: 27b31f9a14d7
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 04:39:22 2012
Log: screenshot tests: create log files and use debug level to ease debugging problems on ci
http://code.google.com/p/robotframework/source/detail?r=27b31f9a14d7

Modified:
 /atest/robot/standard_libraries/screenshot/screenshot.txt
 /atest/robot/standard_libraries/screenshot/take_screenshot.txt

=======================================
--- /atest/robot/standard_libraries/screenshot/screenshot.txt Thu Jul 7 05:11:04 2011 +++ /atest/robot/standard_libraries/screenshot/screenshot.txt Thu Sep 13 04:39:22 2012
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup Run Tests ${EMPTY} standard_libraries/screenshot/screenshot.txt +Suite Setup Run Tests -l log.html -L debug standard_libraries/screenshot/screenshot.txt
 Force Tags      pybot  jybot  regression
 Resource        atest_resource.txt

@@ -36,23 +36,23 @@

 Log Screenshot With Defaults
     ${test} =  Check Test Case  ${TESTNAME}
- Message Should Contain ${test.kws[0].msgs[1]} <img src="screenshot_1.jpg" width="100%"> + Message Should Contain ${test.kws[0].msgs[2]} <img src="screenshot_1.jpg" width="100%">

 Log Screenshot With Filename Defined
     ${test} =  Check Test Case  ${TESTNAME}
- Message Should Contain ${test.kws[0].msgs[1]} <img src="image_1.jpg" width="100%"> + Message Should Contain ${test.kws[0].msgs[2]} <img src="image_1.jpg" width="100%">

 Log Screenshot With Filename And Path Defined
     ${test} =  Check Test Case  ${TESTNAME}
- Message Should Contain ${test.kws[0].msgs[1]} <img src="image_1.jpg" width="100%"> + Message Should Contain ${test.kws[0].msgs[2]} <img src="image_1.jpg" width="100%">

 Log Screenshot With Filename, Path And Width Defined
     ${test} =  Check Test Case  ${TESTNAME}
-    Check Link In Log  ${test.kws[0].msgs[1]}  image_1.jpg  50%
+    Check Link In Log  ${test.kws[0].msgs[2]}  image_1.jpg  50%

 Log Screenshot With Initializing The Screenshot Library
     ${test} =  Check Test Case  ${TESTNAME}
-    Check Link In Log  ${test.kws[0].msgs[1]}  screenshot_1.jpg
+    Check Link In Log  ${test.kws[0].msgs[2]}  screenshot_1.jpg

 *** Keywords ***
 Check Link In Log
=======================================
--- /atest/robot/standard_libraries/screenshot/take_screenshot.txt Thu Jul 7 05:11:04 2011 +++ /atest/robot/standard_libraries/screenshot/take_screenshot.txt Thu Sep 13 04:39:22 2012
@@ -1,5 +1,5 @@
 *** Settings ***
-Suite Setup Run Tests ${EMPTY} standard_libraries/screenshot/take_screenshot.txt +Suite Setup Run Tests -l log.html -L debug standard_libraries/screenshot/take_screenshot.txt
 Force Tags      regression  pybot  jybot
 Resource        atest_resource.txt

@@ -7,30 +7,30 @@

 Screenshot Is Embedded in Log File
     ${tc}=  Check Test Case  ${TESTNAME}
-    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[0]}  screenshot_1.jpg
+    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[1]}  screenshot_1.jpg

 Each Screenshot Gets Separate Index
     ${tc}=  Check Test Case  ${TESTNAME}

 Basename May Be Defined
     ${tc}=  Check Test Case  ${TESTNAME}
-    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[0]}  foo_1.jpg
+    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[1]}  foo_1.jpg

 Basename With Extension Turns Off Index Generation
     ${tc}=  Check Test Case  ${TESTNAME}
-    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[0]}  xxx.jpg
-    Check Embedding In Log  ${tc.kws[1].kws[0].msgs[0]}  yyy.jpEg
+    Check Embedding In Log  ${tc.kws[0].kws[0].msgs[1]}  xxx.jpg
+    Check Embedding In Log  ${tc.kws[1].kws[0].msgs[1]}  yyy.jpEg

 Screenshot Width Can Be Given
     ${tc}=  Check Test Case  ${TESTNAME}
-    Check Embedding In Log  ${tc.kws[0].msgs[0]}  screenshot_1.jpg  300px
+    Check Embedding In Log  ${tc.kws[0].msgs[1]}  screenshot_1.jpg  300px

 Basename With Non-existing Directories Fails
     Check Test Case  ${TESTNAME}

 Without Embedding
     ${tc}=  Check Test Case  ${TESTNAME}
-    Check Linking In Log  ${tc.kws[0].msgs[0]}  no_embed.jpeg
+    Check Linking In Log  ${tc.kws[0].msgs[1]}  no_embed.jpeg


 *** Keywords ***

==============================================================================
Revision: 191a67b93720
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:03:30 2012
Log:      ETWrapper: Worked around IronPython inconsistence.

This fixes creating XML content with XML library using IronPython.

Update issue 1228
Status: Started
Fixed. Still want to clean up the related code a little.
http://code.google.com/p/robotframework/source/detail?r=191a67b93720

Modified:
 /src/robot/utils/etreewrapper.py

=======================================
--- /src/robot/utils/etreewrapper.py    Mon Aug 27 07:06:39 2012
+++ /src/robot/utils/etreewrapper.py    Thu Sep 13 05:03:30 2012
@@ -75,7 +75,7 @@
         if self._source_is_file_name():
             return self._open_source_file()
         if isinstance(self._source, basestring):
-            return StringIO(self._source.encode('UTF-8'))
+            return self._open_string_io(self._source)
         return None

     def _open_source_file(self):
@@ -91,3 +91,6 @@
         if not os.path.exists(self._source):
             raise IOError(2, 'No such file', self._source)
         return None
+
+    def _open_string_io(self, source):
+ return StringIO(source.encode('UTF-8') if not _IRONPYTHON else source)

==============================================================================
Revision: d0a820da2197
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:40:13 2012
Log: ETSource: Cleaned up code dependent on different Python interpreters.

Update issue 1228
Status: Done
Cleaned up the code.
http://code.google.com/p/robotframework/source/detail?r=d0a820da2197

Modified:
 /src/robot/utils/etreewrapper.py

=======================================
--- /src/robot/utils/etreewrapper.py    Thu Sep 13 05:03:30 2012
+++ /src/robot/utils/etreewrapper.py    Thu Sep 13 05:40:13 2012
@@ -73,24 +73,32 @@

     def _open_source_if_necessary(self):
         if self._source_is_file_name():
-            return self._open_source_file()
+            return self._open_file(self._source)
         if isinstance(self._source, basestring):
             return self._open_string_io(self._source)
         return None

-    def _open_source_file(self):
+    if not _IRONPYTHON:
+
# File is opened, and later closed, because ElementTree had a bug that # it didn't close files it had opened. This caused problems with Jython
         # especially on Windows: http://bugs.jython.org/issue1598
# The bug has now been fixed in ET and worked around in Jython 2.5.2.
-        if not _IRONPYTHON:
-            return open(self._source, 'rb')
+        def _open_file(self, source):
+            return open(source, 'rb')
+
+        def _open_string_io(self, source):
+            return StringIO(source.encode('UTF-8'))
+
+    else:
+
# File cannot be opened on IronPython, however, as ET does not seem to # handle non-ASCII characters correctly in that case. We want to check
         # that the file exists even in that case, though.
-        if not os.path.exists(self._source):
-            raise IOError(2, 'No such file', self._source)
-        return None
+        def _open_file(self, source):
+            if not os.path.exists(source):
+                raise IOError(2, 'No such file', source)
+            return None

-    def _open_string_io(self, source):
- return StringIO(source.encode('UTF-8') if not _IRONPYTHON else source)
+        def _open_string_io(self, source):
+            return StringIO(source)

==============================================================================
Revision: 5bec3b42e390
Branch:   default
Author:   Pekka Klärck
Date:     Thu Sep 13 05:46:24 2012
Log: ET/XML library: Cleaned up XML parsing logic dependent on ET versions. Now we check version from ET itself and don't just assume 2.7 interpreters to have 1.3.
http://code.google.com/p/robotframework/source/detail?r=5bec3b42e390

Modified:
 /atest/robot/standard_libraries/xml/xpath.txt
 /atest/testdata/standard_libraries/xml/xpath.txt
 /src/robot/libraries/XML.py
 /src/robot/utils/etreewrapper.py

=======================================
--- /atest/robot/standard_libraries/xml/xpath.txt       Mon Sep 10 03:53:48 2012
+++ /atest/robot/standard_libraries/xml/xpath.txt       Thu Sep 13 05:46:24 2012
@@ -1,6 +1,6 @@
 *** Settings ***
 Suite Setup      Run Tests    ${EMPTY}    standard_libraries/xml/xpath.txt
-Test Setup Make Tests Requiring Python 2.7 Non-Critical If Requirement Not Met +Test Setup Make Tests Requiring ET 1.3 Non-Critical If Requirement Not Met
 Force Tags       regression    pybot    jybot
 Resource         atest_resource.txt

@@ -28,43 +28,47 @@
     Check Test Case    ${TESTNAME}

 '..'
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 '[@attrib]'
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 '[@attrib="value"]'
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 '[tag]'
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 '[position]'
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 Stacked predicates
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 Non-ASCII tag names
     Check Test Case    ${TESTNAME}

 More complex non-ASCII xpath
-    [Tags]    x-requires-2.7+
+    [Tags]    X-Requires-ET-1.3
     Check Test Case    ${TESTNAME}

 Warning when using more complex non-ASCII xpath with interpreter < 2.7
- Run Keyword If '${SUITE.doc}' < '2.7' Verify Non-ASCII xpath error
+    Run Keyword If ET < 1.3    Verify Non-ASCII xpath error

 *** Keywords ***
-Make Tests Requiring Python 2.7 Non-Critical If Requirement Not Met
- Run Keyword If 'x-requires-2.7+' in @{TEST TAGS} and '${SUITE.doc}' < '2.7'
-    ...    Remove Tags    regression
+Make Tests Requiring ET 1.3 Non-Critical If Requirement Not Met
+    Run Keyword If    'X-Requires-ET-1.3' in @{TEST TAGS}
+    ...    Run Keyword If ET < 1.3    Remove Tags    regression
+
+Run Keyword If ET < 1.3
+    [Arguments]    ${kw}    @{args}
+ Run Keyword If '${SUITE.metadata["ET Version"]}' < '1.3' ${kw} @{args}

 Verify Non-ASCII xpath error
     ${tc}=    Get Test Case    More complex non-ASCII xpath
=======================================
--- /atest/testdata/standard_libraries/xml/xpath.txt Fri Jul 6 04:42:41 2012 +++ /atest/testdata/standard_libraries/xml/xpath.txt Thu Sep 13 05:46:24 2012
@@ -95,5 +95,5 @@
Run Keyword If '''${text}''' != 'IGNORE' Should Be Equal ${element.text} ${text}

 Add Interpreter Version to Suite Documentation
-    ${version}=    Evaluate    sys.version[:3]    modules=sys
-    Set Suite Documentation    ${version}
+    ${et}=    Evaluate    robot.utils.ET    modules=robot
+    Set Suite Metadata    ET Version    ${et.VERSION}
=======================================
--- /src/robot/libraries/XML.py Mon Aug  6 05:31:31 2012
+++ /src/robot/libraries/XML.py Thu Sep 13 05:46:24 2012
@@ -336,7 +336,7 @@
             return [source]
         return source.findall(self._get_xpath(xpath))

-    if sys.version_info >= (2, 7):
+    if ET.VERSION >= '1.3':
         def _get_xpath(self, xpath):
             return xpath
     else:
=======================================
--- /src/robot/utils/etreewrapper.py    Thu Sep 13 05:40:13 2012
+++ /src/robot/utils/etreewrapper.py    Thu Sep 13 05:46:24 2012
@@ -46,6 +46,11 @@
         raise ImportError(_ERROR)


+# cElementTree.VERSION seems to always be 1.0.6. We want real API version.
+if ET.VERSION < '1.3' and hasattr(ET, 'tostringlist'):
+    ET.VERSION = '1.3'
+
+
 class ETSource(object):

     def __init__(self, source):

Reply via email to