Revision: 03af636d2e75
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 15 03:44:44 2012
Log: OperatingSystem: add keyword Log Environment Variables
Update issue 1056
Status: Done
http://code.google.com/p/robotframework/source/detail?r=03af636d2e75
Modified:
/atest/robot/standard_libraries/operating_system/env_vars.txt
/atest/testdata/standard_libraries/operating_system/env_vars.txt
/src/robot/libraries/OperatingSystem.py
=======================================
--- /atest/robot/standard_libraries/operating_system/env_vars.txt Sun Feb
12 22:59:57 2012
+++ /atest/robot/standard_libraries/operating_system/env_vars.txt Wed Feb
15 03:44:44 2012
@@ -41,6 +41,10 @@
Use NON-ASCII variable in child process
Check test case ${TEST NAME}
+Log Environment Variables
+ ${tc}= Check test case ${TEST NAME}
+ Check log message ${tc.kws[3].msgs[0]} 0 = value
+ Check log message ${tc.kws[3].msgs[1]} 1 = äiti
*** Keywords ***
Run Tests With Environment Variables
=======================================
--- /atest/testdata/standard_libraries/operating_system/env_vars.txt Sun
Feb 12 22:59:57 2012
+++ /atest/testdata/standard_libraries/operating_system/env_vars.txt Wed
Feb 15 03:44:44 2012
@@ -90,3 +90,13 @@
Set Environment Variable ${NAME} ${NON ASCII}
Test Env Var In Child Process ${NAME}
+Log Environment Variables
+ Set Environment Variable 0 value
+ Set Environment Variable 1 äiti
+ Set Environment Variable isä äiti
+ Log Environment Variables
+ Remove Environment Variable 0
+ Remove Environment Variable 1
+ Remove Environment Variable isä
+ Log Environment Variables
+
=======================================
--- /src/robot/libraries/OperatingSystem.py Wed Feb 15 03:07:42 2012
+++ /src/robot/libraries/OperatingSystem.py Wed Feb 15 03:44:44 2012
@@ -25,7 +25,8 @@
from robot.utils import (ConnectionCache, seq2str, timestr_to_secs,
secs_to_timestr, plural_or_not, get_time,
abspath,
secs_to_timestamp, parse_time, unic,
decode_output,
- get_env_var, set_env_var, del_env_var)
+ get_env_var, set_env_var, del_env_var,
+ decode_from_system)
__version__ = get_version()
PROCESSES = ConnectionCache('No active processes')
del ConnectionCache, get_version
@@ -41,7 +42,7 @@
plural_or_not = lambda count: count != 1 and 's' or ''
secs_to_timestr = lambda secs: '%d second%s' % (secs,
plural_or_not(secs))
unic = unicode
- decode_output = lambda string: string
+ decode_output = decode_from_system = lambda string: string
class _NotImplemented:
def __getattr__(self, name):
raise NotImplementedError('This usage requires Robot
Framework '
@@ -831,9 +832,11 @@
self._fail(msg, "Environment variable '%s' is set to '%s'" %
(name, value))
self._info("Environment variable '%s' is not set" % name)
- def log_environment_variables(self):
+ def log_environment_variables(self, level='INFO'):
+ """Logs all environment variables with given log level."""
for name in sorted(os.environ, key=lambda s: s.lower()):
- self._info('%s = %s' % (name, os.environ[name]))
+ value = decode_from_system(os.environ[name])
+ self._log('%s = %s' % (decode_from_system(name), value), level)
# Path