6 new revisions:

Revision: 397a97d0538b
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:00:26 2013
Log:      refactored parsing args in libdoc
http://code.google.com/p/robotframework/source/detail?r=397a97d0538b

Revision: b21eec6e9288
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:10:17 2013
Log: Removed old 'names' attribute from Argspec. Also changed remaining pla...
http://code.google.com/p/robotframework/source/detail?r=b21eec6e9288

Revision: 5877e8b60c3c
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:19:31 2013
Log: Removed 'supports_named_arguments' attribute from libraries because Li...
http://code.google.com/p/robotframework/source/detail?r=5877e8b60c3c

Revision: 9d41b98d02ac
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 06:51:17 2013
Log:      fixme and whitespace
http://code.google.com/p/robotframework/source/detail?r=9d41b98d02ac

Revision: ddabca52c8ae
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 07:00:15 2013
Log: Refactored handling variables when importing lib/resources/vars. As a ...
http://code.google.com/p/robotframework/source/detail?r=ddabca52c8ae

Revision: 659fbc59a5c5
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 07:20:46 2013
Log: Test and document that named arg syntax works with Import Library....
http://code.google.com/p/robotframework/source/detail?r=659fbc59a5c5

==============================================================================
Revision: 397a97d0538b
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:00:26 2013
Log:      refactored parsing args in libdoc
http://code.google.com/p/robotframework/source/detail?r=397a97d0538b

Modified:
 /src/robot/libdocpkg/robotbuilder.py

=======================================
--- /src/robot/libdocpkg/robotbuilder.py        Mon Apr 29 06:20:30 2013
+++ /src/robot/libdocpkg/robotbuilder.py        Mon May  6 05:00:26 2013
@@ -91,22 +91,15 @@
         return [self.build_keyword(kw) for kw in lib.handlers.values()]

     def build_keyword(self, kw):
- return KeywordDoc(name=kw.name, args=self._get_args(kw), doc=kw.doc)
+        return KeywordDoc(name=kw.name, args=self._get_args(kw.arguments),
+                          doc=kw.doc)

-    def _get_args(self, kw):
-        required, defaults = self._parse_args(kw)
+    def _get_args(self, argspec):
+        required = argspec.positional[:argspec.minargs]
+ defaults = zip(argspec.positional[argspec.minargs:], argspec.defaults)
         args = required + ['%s=%s' % item for item in defaults]
-        if kw.arguments.varargs:
-            args.append('*%s' % kw.arguments.varargs)
-        if kw.arguments.kwargs:
-            args.append('**%s' % kw.arguments.kwargs)
+        if argspec.varargs:
+            args.append('*%s' % argspec.varargs)
+        if argspec.kwargs:
+            args.append('**%s' % argspec.kwargs)
         return args
-
-    def _parse_args(self, kw):
-        args = kw.arguments.names
-        default_count = len(kw.arguments.defaults)
-        if not default_count:
-            return args, []
-        required = args[:-default_count]
-        defaults = zip(args[-default_count:], kw.arguments.defaults)
-        return required, defaults

==============================================================================
Revision: b21eec6e9288
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:10:17 2013
Log: Removed old 'names' attribute from Argspec. Also changed remaining places to use new 'positional' instead.
http://code.google.com/p/robotframework/source/detail?r=b21eec6e9288

Modified:
 /src/robot/running/arguments/argumentspec.py
 /src/robot/running/handlers.py
 /src/robot/running/userkeyword.py

=======================================
--- /src/robot/running/arguments/argumentspec.py        Mon Apr 29 06:04:45 2013
+++ /src/robot/running/arguments/argumentspec.py        Mon May  6 05:10:17 2013
@@ -24,7 +24,6 @@
         self.name = name
         self.type = type
         self.positional = positional or []
-        self.names = self.positional   # FIXME: Remove
         self.defaults = defaults or []
         self.varargs = varargs
         self.kwargs = kwargs
=======================================
--- /src/robot/running/handlers.py      Mon Apr 29 12:41:58 2013
+++ /src/robot/running/handlers.py      Mon May  6 05:10:17 2013
@@ -277,7 +277,7 @@
             return list(self._get_run_kw_if_keywords(args))
         if self._handler_name == 'run_keywords':
             return list(self._get_run_kws_keywords(args))
- if 'name' in self.arguments.names and self._get_args_to_process()
0:
+ if 'name' in self.arguments.positional and self._get_args_to_process() > 0:
             return self._get_default_run_kw_keywords(args)
         return []

@@ -332,7 +332,7 @@
                 yield given_args

     def _get_default_run_kw_keywords(self, given_args):
-        index = self.arguments.names.index('name')
+        index = self.arguments.positional.index('name')
         return [Keyword(given_args[index], given_args[index+1:])]


=======================================
--- /src/robot/running/userkeyword.py   Mon Apr 29 12:41:58 2013
+++ /src/robot/running/userkeyword.py   Mon May  6 05:10:17 2013
@@ -195,7 +195,7 @@
     def _split_args_and_varargs(self, argspec, args):
         if not argspec.varargs:
             return args, []
-        return args[:len(argspec.names)], args[len(argspec.names):]
+ return args[:len(argspec.positional)], args[len(argspec.positional):]

     def _run_teardown(self, context, error):
         if not self.teardown:

==============================================================================
Revision: 5877e8b60c3c
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 05:19:31 2013
Log: Removed 'supports_named_arguments' attribute from libraries because Libdoc didn't need it anymore. Also fixed Libdoc to show that dynamic libs do support named args nowadays.
http://code.google.com/p/robotframework/source/detail?r=5877e8b60c3c

Modified:
 /atest/robot/libdoc/dynamic_library_with_args.txt
 /src/robot/libdocpkg/javabuilder.py
 /src/robot/libdocpkg/model.py
 /src/robot/libdocpkg/robotbuilder.py
 /src/robot/running/testlibraries.py
 /src/robot/running/userkeyword.py

=======================================
--- /atest/robot/libdoc/dynamic_library_with_args.txt Mon Feb 20 12:54:34 2012 +++ /atest/robot/libdoc/dynamic_library_with_args.txt Mon May 6 05:19:31 2013
@@ -23,7 +23,7 @@
     Scope Should Be    test case

 Named Args
-    Named Args Should Be    no
+    Named Args Should Be    yes

 Init Documentation
     Init Doc Should Start With    0   Dummy documentation for `__init__`.
=======================================
--- /src/robot/libdocpkg/javabuilder.py Thu Oct 11 05:02:11 2012
+++ /src/robot/libdocpkg/javabuilder.py Mon May  6 05:19:31 2013
@@ -26,6 +26,7 @@
                             doc=self._get_doc(doc),
                             version=self._get_version(doc),
                             scope=self._get_scope(doc),
+                            named_args=False,
                             doc_format=self._get_doc_format(doc))
         libdoc.keywords = self._keywords(doc)
         libdoc.inits = self._intializers(doc)
=======================================
--- /src/robot/libdocpkg/model.py       Thu Oct 11 04:42:42 2012
+++ /src/robot/libdocpkg/model.py       Mon May  6 05:19:31 2013
@@ -23,7 +23,7 @@
 class LibraryDoc(object):

     def __init__(self, name='', doc='', version='', type='library',
-                 scope='', named_args=False, doc_format=''):
+                 scope='', named_args=True, doc_format=''):
         self.name = name
         self.doc = doc
         self.version = version
=======================================
--- /src/robot/libdocpkg/robotbuilder.py        Mon May  6 05:00:26 2013
+++ /src/robot/libdocpkg/robotbuilder.py        Mon May  6 05:19:31 2013
@@ -33,7 +33,6 @@
                             doc=self._get_doc(lib),
                             version=lib.version,
                             scope=lib.scope,
-                            named_args=lib.supports_named_arguments,
                             doc_format=lib.doc_format)
         libdoc.inits = self._get_initializers(lib)
         libdoc.keywords = KeywordDocBuilder().build_keywords(lib)
@@ -64,7 +63,7 @@
     def build(self, path):
         res = self._import_resource(path)
         libdoc = LibraryDoc(name=res.name, doc=self._get_doc(res),
-                            type='resource', named_args=True)
+                            type='resource')
         libdoc.keywords = KeywordDocBuilder().build_keywords(res)
         return libdoc

=======================================
--- /src/robot/running/testlibraries.py Wed Apr 17 00:47:55 2013
+++ /src/robot/running/testlibraries.py Mon May  6 05:19:31 2013
@@ -56,7 +56,6 @@


 class _BaseTestLibrary(BaseLibrary):
-    supports_named_arguments = True # this attribute is for libdoc
     _log_success = LOGGER.debug
     _log_failure = LOGGER.info
     _log_failure_details = LOGGER.debug
@@ -288,8 +287,6 @@


 class _DynamicLibrary(_BaseTestLibrary):
-    # TODO: Can this be removed now that dynamic libs support named args?
-    supports_named_arguments = False # this attribute is for libdoc
     _log_failure = LOGGER.warn

     def __init__(self, libcode, name, args, variables=None):
=======================================
--- /src/robot/running/userkeyword.py   Mon May  6 05:10:17 2013
+++ /src/robot/running/userkeyword.py   Mon May  6 05:19:31 2013
@@ -29,7 +29,6 @@


 class UserLibrary(BaseLibrary):
-    supports_named_arguments = True # this attribute is for libdoc

     def __init__(self, user_keywords, path=None):
         self.name = self._get_name_for_resource_file(path)

==============================================================================
Revision: 9d41b98d02ac
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 06:51:17 2013
Log:      fixme and whitespace
http://code.google.com/p/robotframework/source/detail?r=9d41b98d02ac

Modified:
 /src/robot/running/testlibraries.py

=======================================
--- /src/robot/running/testlibraries.py Mon May  6 05:19:31 2013
+++ /src/robot/running/testlibraries.py Mon May  6 06:51:17 2013
@@ -75,7 +75,7 @@
             self.doc_format = self._get_doc_format(libcode)
             self.scope = self._get_scope(libcode)
             self._libcode = libcode
-            self.init =  self._create_init_handler(libcode)
+            self.init = self._create_init_handler(libcode)
self.positional_args, self.named_args = self.init.resolve_arguments(args, variables)

     @property
@@ -207,6 +207,7 @@

     def _raise_creating_instance_failed(self):
         msg, details = utils.get_error_details()
+        # FIXME: Error doesn't contain named args
         if self.positional_args:
args = "argument%s %s" % (utils.plural_or_not(self.positional_args),
                                       utils.seq2str(self.positional_args))

==============================================================================
Revision: ddabca52c8ae
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 07:00:15 2013
Log: Refactored handling variables when importing lib/resources/vars. As a bonus, Import Library might support named args now. That needs to be tested separately.
http://code.google.com/p/robotframework/source/detail?r=ddabca52c8ae

Modified:
 /atest/robot/standard_libraries/builtin/import_library.txt
 /atest/robot/standard_libraries/builtin/import_variables.txt
 /atest/testdata/standard_libraries/builtin/import_library.txt
 /atest/testdata/standard_libraries/builtin/import_variables.txt
 /src/robot/libraries/BuiltIn.py
 /src/robot/running/arguments/argumentresolver.py
 /src/robot/running/namespace.py

=======================================
--- /atest/robot/standard_libraries/builtin/import_library.txt Thu May 3 02:47:07 2012 +++ /atest/robot/standard_libraries/builtin/import_library.txt Mon May 6 07:00:15 2013
@@ -12,6 +12,9 @@

 Import Library With Arguments
     Check Test Case  ${TEST NAME}
+
+Import Library With Variables And WITH NAME
+    Check Test Case  ${TEST NAME}

 Import Library Using Physical Path
     Check Test Case  ${TEST NAME}
@@ -19,9 +22,8 @@
 Import Library Using Physical Path, Arguments And WITH NAME
     Check Test Case  ${TEST NAME}

-Import Library Failure Is Catchable
-    Check Test Case  ${TESTNAME}
+Import Library Arguments Are Resolved Only Once
+    Check Test Case  ${TEST NAME}

-'Import Library' keyword should be able to handle special arguments
+Import Library Failure Is Catchable
     Check Test Case  ${TESTNAME}
-
=======================================
--- /atest/robot/standard_libraries/builtin/import_variables.txt Tue Sep 27 06:17:36 2011 +++ /atest/robot/standard_libraries/builtin/import_variables.txt Mon May 6 07:00:15 2013
@@ -20,6 +20,9 @@

 Re-Import Variables
     Check Test Case  ${TEST_NAME}
+
+Import Variables Arguments Are Resolved Only Once
+    Check Test Case  ${TEST NAME}

 Import Variables Failure Is Catchable
     Check Test Case  ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/builtin/import_library.txt Thu May 3 02:47:07 2012 +++ /atest/testdata/standard_libraries/builtin/import_library.txt Mon May 6 07:00:15 2013
@@ -13,10 +13,17 @@
     Directory Should Exist  ${CURDIR}

 Import Library With Arguments
-    Import Library  ParameterLibrary  myhost  4242
-    ${host}  ${port} =  Parameters
-    Should Be Equal  ${host}  myhost
-    Should Be Equal  ${port}  4242
+    Import Library  ParameterLibrary  value  nön-äscii
+    ${first}  ${second} =  Parameters
+    Should Be Equal  ${first}  value
+    Should Be Equal  ${second}  nön-äscii
+
+Import Library With Variables And WITH NAME
+    ${name} =  Set Variable  ParameterLibrary
+    Import Library  ${name}  ${42}  ${name}  WITH NAME  Variables
+    ${first}  ${second} =  Variables.Parameters
+    Should Be Equal  ${first}  ${42}
+    Should Be Equal  ${second}  ParameterLibrary

 Import Library Using Physical Path
     Import Library  ${CURDIR}${/}RegisteredClass.py
@@ -26,15 +33,18 @@
     Should Be Equal  ${ret}  here was a bug

 Import Library Using Physical Path, Arguments And WITH NAME
-    ${dir} =  Normalize Path  ${CURDIR}/../../../testresources/testlibs
- Import Library ${dir}/ParameterLibrary.py first param ${2} WITH NAME Params With Path + Import Library ${CURDIR}/../../../testresources/testlibs/ParameterLibrary.py
+    ...  first param  ${2}  WITH NAME  Params With Path
     ${params} =  Params With Path.Parameters
     Should Be True  ${params} == ('first param', 2)
+
+Import Library Arguments Are Resolved Only Once
+    ${var} =  Set Variable  \${not var}
+    Import Library  ParameterLibrary  c:\\temp  ${var}  WITH NAME  Escaping
+    ${first}  ${second} =  Escaping.Parameters
+    Should Be Equal  ${first}  c:\\temp
+    Should Be Equal  ${second}  \${not var}

 Import Library Failure Is Catchable
Run Keyword And Expect Error Importing test library 'NonExistingLib' failed: ImportError: *
     ...  Import Library  NonExistingLib
-
-'Import Library' keyword should be able to handle special arguments
-    Import Library    ParameterLibrary    ${42}    last
-    Import Library    ParameterLibrary    hyvää päivää    last
=======================================
--- /atest/testdata/standard_libraries/builtin/import_variables.txt Wed Sep 12 15:17:39 2012 +++ /atest/testdata/standard_libraries/builtin/import_variables.txt Mon May 6 07:00:15 2013
@@ -2,6 +2,10 @@
 Suite Setup     Import Variables In Suite Setup
 Library         OperatingSystem

+*** Variables ***
+${VAR FILE 1}   ${CURDIR}/variables_to_import_1.py
+${VAR FILE 2}   ${CURDIR}/variables_to_import_2.py
+
 *** Test Cases ***
 Import Variables In Suite Setup
     Should Be Equal  ${IMPORT_VARIABLES_2_ARGS}  suite setup
@@ -9,7 +13,7 @@

 Import Variables 1
     Variable Should Not Exist  $IMPORT_VARIABLES_1
-    Import Variables  ${CURDIR}${/}variables_to_import_1.py
+    Import Variables  ${VAR FILE 1}
     Should Be Equal  ${IMPORT_VARIABLES_1}  Simple variable file
     Should Be Equal  ${COMMON VARIABLE}  ${1}

@@ -19,11 +23,11 @@

 Import Variables With Arguments
[Documentation] FAIL REGEXP: Processing variable file '.*variables_to_import_2.py' with arguments \\[ 1 | 2 | 3\\] failed: TypeError: .*
-    Import Variables  ${CURDIR}${/}variables_to_import_2.py  my  args
+    Import Variables  ${VAR FILE 2}  my  args
     Should Be Equal  ${IMPORT_VARIABLES_2}  Dynamic variable file
     Should Be Equal  ${IMPORT_VARIABLES_2_ARGS}  my args
     Should Be Equal  ${COMMON VARIABLE}  ${2}
-    Import Variables  ${CURDIR}/variables_to_import_2.py  one arg only
+    Import Variables  ${VAR FILE 2}  one arg only
     Should Be Equal  ${IMPORT_VARIABLES_2}  Dynamic variable file
     Should Be Equal  ${IMPORT_VARIABLES_2_ARGS}  one arg only default
     Should Be Equal  ${COMMON VARIABLE}  ${2}
@@ -51,13 +55,18 @@
     Re-Import And Verify Variables  ${1}
     Re-Import And Verify Variables  ${2}  arg

+Import Variables Arguments Are Resolved Only Once
+    ${var} =  Set Variable  \${not var}
+ Import Variables ${CURDIR}${/}variables_to_import_2.py ${var} c:\\temp
+    Should Be Equal  ${IMPORT VARIABLES 2 ARGS}  \${not var} c:\\temp
+
 Import Variables Failure Is Catchable
Run Keyword And Expect Error Variable file 'non_existing.py' does not exist. Import Variables non_existing.py

 *** Keywords ***
 Import Variables In User Keyword
     [Arguments]  @{value}
-    Import Variables  ${CURDIR}${/}variables_to_import_2.py  @{value}
+    Import Variables  ${VAR FILE 2}  @{value}
     ${value} =  Catenate  @{value}
     Should Be Equal  ${IMPORT_VARIABLES_2_ARGS}  ${value}
     Imported Variable Should Be Set To  ${value}
=======================================
--- /src/robot/libraries/BuiltIn.py     Mon May  6 03:48:33 2013
+++ /src/robot/libraries/BuiltIn.py     Mon May  6 07:00:15 2013
@@ -1753,12 +1753,10 @@
         table.

         This keyword supports importing libraries both using library
-        names and physical paths. When path are used, they must be
+        names and physical paths. When paths are used, they must be
         given in absolute format. Forward slashes can be used as path
         separators in all operating systems. It is possible to use
-        arguments as well as to give a custom name with 'WITH NAME'
-        syntax. For more information about importing libraries, see
-        Robot Framework User Guide.
+        arguments and to give a custom name with 'WITH NAME' syntax.

         Examples:
         | Import Library | MyLibrary |
@@ -1776,8 +1774,8 @@
Variables imported with this keyword are set into the test suite scope similarly when importing them in the Setting table using the Variables
         setting. These variables override possible existing variables with
- the same names and this functionality can thus be used to import new
-        variables, e.g. for each test in a test suite.
+        the same names. This functionality can thus be used to import new
+        variables, for example, for each test in a test suite.

The given path must be absolute. Forward slashes can be used as path
         separator regardless the operating system.
@@ -2336,6 +2334,7 @@
     register_run_keyword('BuiltIn', getattr(_RunKeyword, name))
for name in ['set_test_variable', 'set_suite_variable', 'set_global_variable',
              'variable_should_exist', 'variable_should_not_exist', 'comment',
-             'get_variable_value']:
+             'get_variable_value', 'import_library', 'import_variables',
+             'import_resource']:
     register_run_keyword('BuiltIn', name, 0)
 del name, attr
=======================================
--- /src/robot/running/arguments/argumentresolver.py Fri May 3 03:37:15 2013 +++ /src/robot/running/arguments/argumentresolver.py Mon May 6 07:00:15 2013
@@ -26,7 +26,7 @@
         self._variable_replacer = VariableReplacer(resolve_variables_until)
         self._argument_validator = ArgumentValidator(argspec)

-    def resolve(self, arguments, variables):
+    def resolve(self, arguments, variables=None):
         positional, named = self._named_resolver.resolve(arguments)
positional, named = self._variable_replacer.replace(positional, named,
                                                             variables)
@@ -97,8 +97,8 @@
     def __init__(self, resolve_until=None):
         self._resolve_until = resolve_until

-    def replace(self, positional, named, variables):
-        # TODO: Why/when can variables be None?
+    def replace(self, positional, named, variables=None):
+        # `variables` is None when using Libdoc
         if variables:
positional = variables.replace_list(positional, self._resolve_until)
             named = dict((name, variables.replace_scalar(value))
=======================================
--- /src/robot/running/namespace.py     Mon Apr 29 00:46:01 2013
+++ /src/robot/running/namespace.py     Mon May  6 07:00:15 2013
@@ -86,15 +86,15 @@
         action = {'Library': self._import_library,
                   'Resource': self._import_resource,
                   'Variables': self._import_variables}[import_setting.type]
-        action(import_setting, self.variables.current)
+        action(import_setting)

     def import_resource(self, name, overwrite=True):
         self._import_resource(Resource(None, name), overwrite=overwrite)

- def _import_resource(self, import_setting, variables=None, overwrite=False):
+    def _import_resource(self, import_setting, overwrite=False):
if import_setting.type == "Resource" and INIT_FILE_MATCHER.match(import_setting.name): raise DataError("Initialization files cannot be imported as resources.")
-        path = self._resolve_name(import_setting, variables)
+        path = self._resolve_name(import_setting)
         if overwrite or path not in self._imported_resource_files:
             resource = IMPORTER.import_resource(path)
             self.variables.set_from_variable_table(resource.variable_table,
@@ -106,12 +106,12 @@
             LOGGER.info("Resource file '%s' already imported by suite '%s'"
                         % (path, self.suite.longname))

- def import_variables(self, name, args, overwrite=False, variables=None): - self._import_variables(Variables(None, name, args), variables, overwrite)
+    def import_variables(self, name, args, overwrite=False):
+        self._import_variables(Variables(None, name, args), overwrite)

- def _import_variables(self, import_setting, variables, overwrite=False):
-        path = self._resolve_name(import_setting, variables)
-        args = self._resolve_args(import_setting, variables)
+    def _import_variables(self, import_setting, overwrite=False):
+        path = self._resolve_name(import_setting)
+        args = self._resolve_args(import_setting)
         if overwrite or (path, args) not in self._imported_variable_files:
             self._imported_variable_files.add((path,args))
             self.variables.set_from_file(path, args, overwrite)
@@ -122,13 +122,13 @@
             LOGGER.info("%s already imported by suite '%s'"
                         % (msg, self.suite.longname))

-    def import_library(self, name, args=None, alias=None, variables=None):
- self._import_library(Library(None, name, args=args, alias=alias), variables)
+    def import_library(self, name, args=None, alias=None):
+        self._import_library(Library(None, name, args=args, alias=alias))

-    def _import_library(self, import_setting, variables):
-        name = self._resolve_name(import_setting, variables)
+    def _import_library(self, import_setting):
+        name = self._resolve_name(import_setting)
         lib = IMPORTER.import_library(name, import_setting.args,
-                                      import_setting.alias, variables)
+                                      import_setting.alias, self.variables)
         if lib.name in self._testlibs:
             LOGGER.info("Test library '%s' already imported by suite '%s'"
                         % (lib.name, self.suite.longname))
@@ -139,13 +139,12 @@
             lib.start_test()
         self._import_deprecated_standard_libs(lib.name)

-    def _resolve_name(self, import_setting, variables):
+    def _resolve_name(self, import_setting):
         name = import_setting.name
-        if variables:
-            try:
-                name = variables.replace_string(name)
-            except DataError, err:
-                self._raise_replacing_vars_failed(import_setting, err)
+        try:
+            name = self.variables.replace_string(name)
+        except DataError, err:
+            self._raise_replacing_vars_failed(import_setting, err)
return self._get_path(name, import_setting.directory, import_setting.type)

     def _raise_replacing_vars_failed(self, import_setting, err):
@@ -182,11 +181,9 @@
                 'Resource': 'Resource file'}[type]
         raise DataError("%s '%s' does not exist." % (type, path))

-    def _resolve_args(self, import_setting, variables):
-        if not variables:
-            return import_setting.args
+    def _resolve_args(self, import_setting):
         try:
-            return variables.replace_list(import_setting.args)
+            return self.variables.replace_list(import_setting.args)
         except DataError, err:
             self._raise_replacing_vars_failed(import_setting, err)


==============================================================================
Revision: 659fbc59a5c5
Branch:   default
Author:   Robot Framework Developers ([email protected])
Date:     Mon May  6 07:20:46 2013
Log:      Test and document that named arg syntax works with Import Library.

Update issue 1424
Status: Done
Owner: pekka.klarck
This was already implemented as a by-product of a recent refactoring to
handling variables when importing libraries. Now named args functionality is
also tested and documented
http://code.google.com/p/robotframework/source/detail?r=659fbc59a5c5

Modified:
 /atest/robot/standard_libraries/builtin/import_library.txt
 /atest/testdata/standard_libraries/builtin/import_library.txt
 /src/robot/libraries/BuiltIn.py

=======================================
--- /atest/robot/standard_libraries/builtin/import_library.txt Mon May 6 07:00:15 2013 +++ /atest/robot/standard_libraries/builtin/import_library.txt Mon May 6 07:20:46 2013
@@ -24,6 +24,9 @@

 Import Library Arguments Are Resolved Only Once
     Check Test Case  ${TEST NAME}
+
+Import Library With Named Arguments
+    Check Test Case  ${TEST NAME}

 Import Library Failure Is Catchable
     Check Test Case  ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/builtin/import_library.txt Mon May 6 07:00:15 2013 +++ /atest/testdata/standard_libraries/builtin/import_library.txt Mon May 6 07:20:46 2013
@@ -44,6 +44,12 @@
     ${first}  ${second} =  Escaping.Parameters
     Should Be Equal  ${first}  c:\\temp
     Should Be Equal  ${second}  \${not var}
+
+Import Library With Named Arguments
+ Import Library ParameterLibrary port=${2} host=first WITH NAME Named
+    ${first}  ${second} =  Named.Parameters
+    Should Be Equal  ${first}  first
+    Should Be Equal  ${second}  ${2}

 Import Library Failure Is Catchable
Run Keyword And Expect Error Importing test library 'NonExistingLib' failed: ImportError: *
=======================================
--- /src/robot/libraries/BuiltIn.py     Mon May  6 07:00:15 2013
+++ /src/robot/libraries/BuiltIn.py     Mon May  6 07:20:46 2013
@@ -1755,13 +1755,16 @@
         This keyword supports importing libraries both using library
         names and physical paths. When paths are used, they must be
         given in absolute format. Forward slashes can be used as path
-        separators in all operating systems. It is possible to use
-        arguments and to give a custom name with 'WITH NAME' syntax.
+        separators in all operating systems.
+
+        It is possible to pass arguments to the imported library and also
+        named argument syntax works if the library supports it. 'WITH NAME'
+        syntax can be used to give a custom name to the imported library.

         Examples:
         | Import Library | MyLibrary |
-        | Import Library | ${CURDIR}/Library.py | some | args |
- | Import Library | ${CURDIR}/../libs/Lib.java | arg | WITH NAME | JavaLib |
+        | Import Library | ${CURDIR}/../Library.py | arg1 | named=arg2 |
+ | Import Library | ${LIBRARIES}/Lib.java | arg | WITH NAME | JavaLib |
         """
         try:
self._namespace.import_library(name.replace('/', os.sep), list(args))

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to