Revision: 4490
Author: robotframework
Date: Thu Dec  9 08:18:02 2010
Log: better handling for deprecated log_file_dir when it is given to __init__
http://code.google.com/p/robotframework/source/detail?r=4490

Modified:
 /trunk/atest/robot/standard_libraries/screenshot/screenshot.txt
 /trunk/atest/testdata/standard_libraries/screenshot/screenshot.txt
 /trunk/src/robot/libraries/Screenshot.py

=======================================
--- /trunk/atest/robot/standard_libraries/screenshot/screenshot.txt Thu Dec 9 07:01:19 2010 +++ /trunk/atest/robot/standard_libraries/screenshot/screenshot.txt Thu Dec 9 08:18:02 2010
@@ -49,7 +49,8 @@

 Log Screenshot With Initializing The Screenshot Library
     ${test} =  Check Test Case  ${TESTNAME}
-    Check Link In Log  ${test.kws[0].msgs[0]}  screenshot_1.jpg
+ Check Log Message ${test.kws[0].msgs[0]} Argument `log_file_directory` given to Screenshot library is deprecated and should not be used. WARN
+    Check Link In Log  ${test.kws[0].msgs[1]}  screenshot_1.jpg

 *** Keywords ***
 Check Link In Log
=======================================
--- /trunk/atest/testdata/standard_libraries/screenshot/screenshot.txt Thu Dec 9 07:00:21 2010 +++ /trunk/atest/testdata/standard_libraries/screenshot/screenshot.txt Thu Dec 9 08:18:02 2010
@@ -3,7 +3,7 @@
 Test Setup      Save Start Time
 Test Teardown   Remove Files  @{SCREENSHOTS}
 Resource        screenshot_resource.txt
-Library Screenshot ${OUTPUTDIR} ${OUTPUTDIR} WITH NAME Screenshot2 +Library Screenshot ${OUTPUTDIR} this is deprecated WITH NAME Screenshot2

 *** Variables ***
@{SCREENSHOTS} ${OUTPUTDIR}${/}screenshot_1.jpg ${OUTPUTDIR}${/}screenshot_2.jpg
=======================================
--- /trunk/src/robot/libraries/Screenshot.py    Thu Dec  9 08:00:26 2010
+++ /trunk/src/robot/libraries/Screenshot.py    Thu Dec  9 08:18:02 2010
@@ -110,7 +110,7 @@
         effect. The information provided with it earlier is nowadays got
         automatically. This argument will be removed in the 2.6 release.
         """
-        self._warn_if_deprecated_argument_was_used(log_file_directory)
+        self._depr_log_file_dir_given_to_init = log_file_directory
         self._given_screenshot_dir = self._norm_path(screenshot_directory)
         self._screenshot_taker = ScreenshotTaker()

@@ -184,7 +184,7 @@
         effect. The information provided with it earlier is nowadays got
         automatically.
         """
-        self._warn_if_deprecated_argument_was_used(log_file_directory)
+        self._warn_if_depr_log_file_dir_given(log_file_directory)
         path = self._save_screenshot(basename, directory)
         self._embed_screenshot(path, width)
         return path
@@ -235,6 +235,7 @@
         return self._screenshot_to_file(path)

     def _screenshot_to_file(self, path):
+        self._warn_if_depr_log_file_dir_given_to_init()
         path = os.path.abspath(self._norm_path(path))
         self._validate_screenshot_path(path)
         print '*DEBUG* Using %s modules for taking screenshot.' \
@@ -267,8 +268,14 @@
         link = utils.get_link_path(path, self._log_dir)
print "*HTML* Screenshot saved to '<a href=\"%s\">%s</a>'." % (link, path)

-    def _warn_if_deprecated_argument_was_used(self, log_file_directory):
-        if log_file_directory != 'DEPRECATED':
+    def _warn_if_depr_log_file_dir_given_to_init(self):
+        if self._depr_log_file_dir_given_to_init != 'DEPRECATED':
+ print '*WARN* Argument `log_file_directory` given to Screenshot ' \
+                + 'library is deprecated and should not be used.'
+            self._depr_log_file_dir_given_to_init = 'DEPRECATED'
+
+    def _warn_if_depr_log_file_dir_given(self, given_value):
+        if given_value != 'DEPRECATED':
print '*WARN* Argument `log_file_directory` is deprecated and should not be used.'


Reply via email to