3 new revisions:
Revision: 6c3f3ac1d55a
Author: Pekka Klärck
Date: Tue Dec 20 05:18:32 2011
Log: import cleanup
http://code.google.com/p/robotframework/source/detail?r=6c3f3ac1d55a
Revision: 28dbe4f7ad70
Author: Pekka Klärck
Date: Tue Dec 20 13:45:05 2011
Log: Execution context: Instead of keeping OUTPUT and NAMESPACES in
global ...
http://code.google.com/p/robotframework/source/detail?r=28dbe4f7ad70
Revision: b53faa866b99
Author: Pekka Klärck
Date: Tue Dec 20 13:45:38 2011
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=b53faa866b99
==============================================================================
Revision: 6c3f3ac1d55a
Author: Pekka Klärck
Date: Tue Dec 20 05:18:32 2011
Log: import cleanup
http://code.google.com/p/robotframework/source/detail?r=6c3f3ac1d55a
Modified:
/src/robot/output/output.py
=======================================
--- /src/robot/output/output.py Fri Nov 11 02:21:37 2011
+++ /src/robot/output/output.py Tue Dec 20 05:18:32 2011
@@ -14,12 +14,11 @@
from robot.common.statistics import Statistics
-from loggerhelper import AbstractLogger
-from logger import LOGGER
-from xmllogger import XmlLogger
-from listeners import Listeners
-from debugfile import DebugFile
-from stdoutlogsplitter import StdoutLogSplitter
+from .listeners import Listeners
+from .logger import LOGGER
+from .loggerhelper import AbstractLogger
+from .debugfile import DebugFile
+from .xmllogger import XmlLogger
class Output(AbstractLogger):
==============================================================================
Revision: 28dbe4f7ad70
Author: Pekka Klärck
Date: Tue Dec 20 13:45:05 2011
Log: Execution context: Instead of keeping OUTPUT and NAMESPACES in
global state keep EXECUTION_CONTEXTS that has both of them. This is still
pretty fugly but necessary e.g. due to BuiltIn until this whole stuff is
refactored at some point.
http://code.google.com/p/robotframework/source/detail?r=28dbe4f7ad70
Modified:
/src/robot/libraries/BuiltIn.py
/src/robot/output/__init__.py
/src/robot/output/output.py
/src/robot/running/__init__.py
/src/robot/running/context.py
/src/robot/running/model.py
/src/robot/running/namespace.py
/src/robot/running/userkeyword.py
=======================================
--- /src/robot/libraries/BuiltIn.py Sat Dec 10 12:53:04 2011
+++ /src/robot/libraries/BuiltIn.py Tue Dec 20 13:45:05 2011
@@ -21,8 +21,8 @@
from robot import utils
from robot.utils import asserts
from robot.variables import is_var, is_list_var
-from robot.running import Keyword, NAMESPACES, RUN_KW_REGISTER
-from robot.running.model import ExecutionContext
+from robot.running import Keyword, RUN_KW_REGISTER
+from robot.running.context import EXECUTION_CONTEXTS
from robot.common import UserErrorHandler
from robot.version import get_version
from robot.model import TagPatterns
@@ -787,7 +787,7 @@
def get_variables(self):
"""Returns a dictionary containing all variables in the current
scope."""
- return self._namespace.variables
+ return self._variables
def get_variable_value(self, name, default=None):
"""Returns variable value or `default` if the variable does not
exist.
@@ -1035,7 +1035,7 @@
another keyword or from the command line.
"""
kw = Keyword(name, list(args))
- return kw.run(ExecutionContext(self._namespace, self._output))
+ return kw.run(self._execution_context)
def run_keywords(self, *names):
"""Executes all the given keywords in a sequence without arguments.
@@ -1055,8 +1055,7 @@
self.run_keyword(kw)
except ExecutionFailed, err:
errors.extend(err.get_errors())
- context = ExecutionContext(self._namespace, self._output)
- if not err.can_continue(context.teardown):
+ if not err.can_continue(self._execution_context.teardown):
break
if errors:
raise ExecutionFailures(errors)
@@ -1269,10 +1268,10 @@
"""
values = self._verify_values_for_set_variable_if(list(values))
if self._is_true(condition):
- return self._namespace.variables.replace_scalar(values[0])
+ return self._variables.replace_scalar(values[0])
values = self._verify_values_for_set_variable_if(values[1:], True)
if len(values) == 1:
- return self._namespace.variables.replace_scalar(values[0])
+ return self._variables.replace_scalar(values[0])
return self.run_keyword('BuiltIn.Set Variable If', *values[0:])
def _verify_values_for_set_variable_if(self, values, default=False):
@@ -1282,7 +1281,7 @@
raise RuntimeError('At least one value is required')
if is_list_var(values[0]):
values[:1] = [utils.escape(item) for item in
- self._namespace.variables[values[0]]]
+ self._variables[values[0]]]
return self._verify_values_for_set_variable_if(values)
return values
@@ -1507,7 +1506,7 @@
logging).
"""
try:
- old = self._output.set_log_level(level)
+ old = self._execution_context.output.set_log_level(level)
except DataError, err:
raise RuntimeError(unicode(err))
self.log('Log level changed from %s to %s' % (old, level.upper()))
@@ -1899,18 +1898,16 @@
ROBOT_LIBRARY_VERSION = get_version()
@property
- def _output(self):
- # OUTPUT is initially set to None and gets real value only when
actual
- # execution starts. If BuiltIn is used externally before that,
OUTPUT
- # gets None value. For more information see this bug report:
- # http://code.google.com/p/robotframework/issues/detail?id=654
- # TODO: Refactor running so that OUTPUT is available via context
- from robot.output import OUTPUT
- return OUTPUT
+ def _execution_context(self):
+ return EXECUTION_CONTEXTS.current
@property
def _namespace(self):
- return NAMESPACES.current
+ return self._execution_context.namespace
+
+ @property
+ def _variables(self):
+ return self._namespace.variables
def _matches(self, string, pattern):
# Must use this instead of fnmatch when string may contain
newlines.
=======================================
--- /src/robot/output/__init__.py Mon Dec 12 04:17:13 2011
+++ /src/robot/output/__init__.py Tue Dec 20 13:45:05 2011
@@ -19,10 +19,6 @@
from loggerhelper import LEVELS, Message
-# Hooks to output. Set by Output.
-# Use only if no other way available (e.g. from BuiltIn library)
-OUTPUT = None
-
#TODO: Fix Public API
def TestSuite(outpath):
"""Factory method for getting test suite from an xml output file.
=======================================
--- /src/robot/output/output.py Tue Dec 20 05:18:32 2011
+++ /src/robot/output/output.py Tue Dec 20 13:45:05 2011
@@ -28,7 +28,6 @@
self._xmllogger = XmlLogger(settings['Output'],
settings['LogLevel'])
self._register_loggers(settings['Listeners'],
settings['DebugFile'])
self._settings = settings
- self._set_global_output()
def _register_loggers(self, listeners, debugfile):
LOGGER.register_context_changing_logger(self._xmllogger)
@@ -36,11 +35,6 @@
if logger: LOGGER.register_logger(logger)
LOGGER.disable_message_cache()
- def _set_global_output(self):
- # This is a hack. Hopefully we get rid of it at some point.
- from robot import output
- output.OUTPUT = self
-
def close(self, suite):
stats = Statistics(suite, self._settings['SuiteStatLevel'],
self._settings['TagStatInclude'],
=======================================
--- /src/robot/running/__init__.py Thu Aug 11 23:52:56 2011
+++ /src/robot/running/__init__.py Tue Dec 20 13:45:05 2011
@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from model import TestSuite
-from keywords import Keyword
-from testlibraries import TestLibrary
-from runkwregister import RUN_KW_REGISTER
-from signalhandler import STOP_SIGNAL_MONITOR
+from .model import TestSuite
+from .keywords import Keyword
+from .testlibraries import TestLibrary
+from .runkwregister import RUN_KW_REGISTER
+from .signalhandler import STOP_SIGNAL_MONITOR
+from .context import EXECUTION_CONTEXTS
def UserLibrary(path):
@@ -38,24 +38,3 @@
ret.doc = resource.setting_table.doc.value
return ret
-
-class _Namespaces:
-
- def __init__(self):
- self._namespaces = []
- self.current = None
-
- def start_suite(self, namespace):
- self._namespaces.append(self.current)
- self.current = namespace
-
- def end_suite(self):
- self.current = self._namespaces.pop()
-
- def __iter__(self):
- namespaces = self._namespaces + [self.current]
- return iter([ns for ns in namespaces if ns is not None])
-
-
-# Hook to namespaces
-NAMESPACES = _Namespaces()
=======================================
--- /src/robot/running/context.py Fri May 6 06:28:25 2011
+++ /src/robot/running/context.py Tue Dec 20 13:45:05 2011
@@ -15,7 +15,35 @@
from robot.variables import GLOBAL_VARIABLES
-class ExecutionContext(object):
+class ExecutionContexts(object):
+
+ def __init__(self):
+ self._contexts = []
+
+ @property
+ def current(self):
+ return self._contexts[-1] if self._contexts else None
+
+ def __iter__(self):
+ return iter(self._contexts)
+
+ @property
+ def namespaces(self):
+ return (context.namespace for context in self)
+
+ def start_suite(self, namespace, output, dry_run=False):
+ self._contexts.append(_ExecutionContext(namespace, output,
dry_run))
+ return self.current
+
+ def end_suite(self):
+ self._contexts.pop()
+
+
+# This is ugly but currently needed e.g. by BuiltIn
+EXECUTION_CONTEXTS = ExecutionContexts()
+
+
+class _ExecutionContext(object):
def __init__(self, namespace, output, dry_run=False):
self.namespace = namespace
@@ -47,6 +75,7 @@
def end_suite(self, suite):
self.output.end_suite(suite)
self.namespace.end_suite()
+ EXECUTION_CONTEXTS.end_suite()
def output_file_changed(self, filename):
self._set_global_variable('${OUTPUT_FILE}', filename)
@@ -95,6 +124,12 @@
def end_keyword(self, keyword):
self.output.end_keyword(keyword)
+ def start_user_keyword(self, kw):
+ self.namespace.start_user_keyword(kw)
+
+ def end_user_keyword(self):
+ self.namespace.end_user_keyword()
+
def warn(self, message):
self.output.warn(message)
=======================================
--- /src/robot/running/model.py Thu Aug 11 23:52:20 2011
+++ /src/robot/running/model.py Tue Dec 20 13:45:05 2011
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
-
from robot import utils
from robot.common import BaseTestSuite, BaseTestCase
from robot.parsing import TestData
@@ -21,14 +19,14 @@
from robot.variables import GLOBAL_VARIABLES
from robot.output import LOGGER
-from fixture import (Setup, Teardown, SuiteSetupListener,
SuiteTearDownListener,
- TestSetupListener, TestTeardownListener)
-from keywords import Keywords
-from namespace import Namespace
-from runerrors import SuiteRunErrors, TestRunErrors
-from userkeyword import UserLibrary
-from context import ExecutionContext
-from defaultvalues import DefaultValues
+from .fixture import (Setup, Teardown, SuiteSetupListener,
SuiteTearDownListener,
+ TestSetupListener, TestTeardownListener)
+from .keywords import Keywords
+from .namespace import Namespace
+from .runerrors import SuiteRunErrors, TestRunErrors
+from .userkeyword import UserLibrary
+from .context import EXECUTION_CONTEXTS
+from .defaultvalues import DefaultValues
def TestSuite(datasources, settings):
@@ -126,7 +124,7 @@
self.starttime = utils.get_timestamp()
parent_vars = parent.context.get_current_vars() if parent else None
ns = Namespace(self, parent_vars, skip_imports=errors.exit)
- self.context = ExecutionContext(ns, output, self._run_mode_dry_run)
+ self.context = EXECUTION_CONTEXTS.start_suite(ns, output,
self._run_mode_dry_run)
self._set_variable_dependent_metadata(self.context)
output.start_suite(self)
return self.context
=======================================
--- /src/robot/running/namespace.py Fri Oct 14 13:48:15 2011
+++ /src/robot/running/namespace.py Tue Dec 20 13:45:05 2011
@@ -22,12 +22,12 @@
from robot.common import UserErrorHandler
from robot.output import LOGGER
from robot.parsing.settings import Library, Variables, Resource
-import robot
-
-from userkeyword import UserLibrary
-from importer import Importer, ImportCache
-from runkwregister import RUN_KW_REGISTER
-from handlers import _XTimesHandler
+
+from .userkeyword import UserLibrary
+from .importer import Importer, ImportCache
+from .runkwregister import RUN_KW_REGISTER
+from .handlers import _XTimesHandler
+from .context import EXECUTION_CONTEXTS
STDLIB_NAMES =
['BuiltIn', 'Collections', 'Dialogs', 'Easter', 'OperatingSystem',
@@ -42,7 +42,6 @@
"""
def __init__(self, suite, parent_vars, skip_imports=False):
- robot.running.NAMESPACES.start_suite(self)
if suite is not None:
LOGGER.info("Initializing namespace for test suite '%s'" %
suite.longname)
self.variables = self._create_variables(suite, parent_vars)
@@ -218,7 +217,6 @@
self.variables.end_suite()
for lib in self._testlibs.values():
lib.end_suite()
- robot.running.NAMESPACES.end_suite()
def start_user_keyword(self, handler):
self.variables.start_uk(handler)
@@ -490,7 +488,7 @@
def set_global(self, name, value):
GLOBAL_VARIABLES.__setitem__(name, value)
- for ns in robot.running.NAMESPACES:
+ for ns in EXECUTION_CONTEXTS.namespaces:
ns.variables.set_suite(name, value)
def set_suite(self, name, value):
=======================================
--- /src/robot/running/userkeyword.py Mon Dec 19 13:25:17 2011
+++ /src/robot/running/userkeyword.py Tue Dec 20 13:45:05 2011
@@ -126,11 +126,11 @@
self.timeout.replace_variables(varz)
def run(self, context, arguments):
- context.namespace.start_user_keyword(self)
+ context.start_user_keyword(self)
try:
return self._run(context, arguments)
finally:
- context.namespace.end_user_keyword()
+ context.end_user_keyword()
def _run(self, context, argument_values):
args_spec = UserKeywordArguments(self._keyword_args, self.longname)
==============================================================================
Revision: b53faa866b99
Author: Pekka Klärck
Date: Tue Dec 20 13:45:38 2011
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=b53faa866b99