2 new revisions:
Revision: 56735b09f1b6
Author: Pekka Klärck
Date: Wed Jan 4 05:10:42 2012
Log: small library import cleanup. also include named arguments to
syslog m...
http://code.google.com/p/robotframework/source/detail?r=56735b09f1b6
Revision: 8b20ee93483f
Author: Pekka Klärck
Date: Wed Jan 4 05:33:00 2012
Log: tests for importing libraries using named arguments. these prove
that ...
http://code.google.com/p/robotframework/source/detail?r=8b20ee93483f
==============================================================================
Revision: 56735b09f1b6
Author: Pekka Klärck
Date: Wed Jan 4 05:10:42 2012
Log: small library import cleanup. also include named arguments to
syslog messages.
http://code.google.com/p/robotframework/source/detail?r=56735b09f1b6
Modified:
/src/robot/running/importer.py
=======================================
--- /src/robot/running/importer.py Tue Jan 3 06:42:40 2012
+++ /src/robot/running/importer.py Wed Jan 4 05:10:42 2012
@@ -47,21 +47,25 @@
return self._resource_cache[path]
def _import_library(self, name, positional, named, lib):
+ args = positional + ['%s=%s' % arg for arg in
sorted(named.items())]
key = (name, positional, named)
if key in self._library_cache:
LOGGER.info("Found test library '%s' with arguments %s from
cache"
- % (name, utils.seq2str2(positional)))
+ % (name, utils.seq2str2(args)))
return self._library_cache[key]
lib.create_handlers()
self._library_cache[key] = lib
- libtype = lib.__class__.__name__.replace('Library', '').lower()[1:]
+ self._log_imported_library(name, args, lib)
+ return lib
+
+ def _log_imported_library(self, name, args, lib):
+ type = lib.__class__.__name__.replace('Library', '').lower()[1:]
LOGGER.info("Imported library '%s' with arguments %s "
"(version %s, %s type, %s scope, %d keywords)"
- % (name, utils.seq2str2(positional), lib.version,
- libtype, lib.scope.lower(), len(lib)))
+ % (name, utils.seq2str2(args), lib.version,
+ type, lib.scope.lower(), len(lib)))
if not lib:
LOGGER.warn("Imported library '%s' contains no keywords" %
name)
- return lib
def _copy_library(self, lib, newname):
libcopy = copy.copy(lib)
==============================================================================
Revision: 8b20ee93483f
Author: Pekka Klärck
Date: Wed Jan 4 05:33:00 2012
Log: tests for importing libraries using named arguments. these prove
that refactoring i had in mind would not work.
http://code.google.com/p/robotframework/source/detail?r=8b20ee93483f
Modified:
/atest/robot/test_libraries/library_imports_with_args.txt
/atest/testdata/test_libraries/library_imports_with_args.txt
=======================================
--- /atest/robot/test_libraries/library_imports_with_args.txt Tue Jul 13
07:00:06 2010
+++ /atest/robot/test_libraries/library_imports_with_args.txt Wed Jan 4
05:33:00 2012
@@ -14,7 +14,9 @@
Default values
libswithargs.Defaults m1
libswithargs.Defaults m2 d1
- libswithargs.Defaults m3 1 2
+ libswithargs.Defaults m3 1 default2=2
+ libswithargs.Defaults m4 default2=d2
+ libswithargs.Defaults m5 default2=d1
Varargs
libswithargs.Varargs m1
@@ -24,12 +26,13 @@
Mixed
libswithargs.Mixed m1
libswithargs.Mixed m2 d1
- libswithargs.Mixed m3 d2 v
- libswithargs.Mixed m4 d3 v1 v2
+ libswithargs.Mixed m3 default=d1
+ libswithargs.Mixed m4 d2 v
+ libswithargs.Mixed m5 d3 v1 v2
Variables containing objects
libswithargs.Mixed [1, 2, 3, 4, 'foo', 'bar'] {'a': 1} None 42
- libswithargs.Defaults None 1.0 True
+ libswithargs.Defaults None 1.0 default2=not named
Too Few Arguments
[Template] Library import should have failed
=======================================
--- /atest/testdata/test_libraries/library_imports_with_args.txt Tue Jul 13
07:00:06 2010
+++ /atest/testdata/test_libraries/library_imports_with_args.txt Wed Jan 4
05:33:00 2012
@@ -1,9 +1,11 @@
*** Settings ***
Library libswithargs.Mandatory first arg another arg
-Library libswithargs.Defaults m1 WITH NAME D1
-Library libswithargs.Defaults m2 d1 WITH NAME D2
-Library libswithargs.Defaults m3 ${1} ${2} WITH NAME D3
+Library libswithargs.Defaults m1 WITH NAME D1
+Library libswithargs.Defaults m2 d1 WITH NAME D2
+Library libswithargs.Defaults m3 ${1} default2=${2} WITH NAME D3
+Library libswithargs.Defaults m4 default2=d2 WITH NAME D4
+Library libswithargs.Defaults m5 ${NOT NAMED} WITH NAME D5
Library libswithargs.Varargs m1 WITH NAME V1
Library libswithargs.Varargs m2 v1 WITH NAME V2
@@ -11,8 +13,9 @@
Library libswithargs.Mixed m1 WITH NAME M1
Library libswithargs.Mixed m2 d1 WITH NAME M2
-Library libswithargs.Mixed m3 d2 v WITH NAME M3
-Library libswithargs.Mixed m4 d3 v1 v2 WITH NAME M4
+Library libswithargs.Mixed m3 default=d1 WITH NAME M3
+Library libswithargs.Mixed m4 d2 v WITH NAME M4
+Library libswithargs.Mixed m5 d3 v1 v2 WITH NAME M5
Variables ../../testresources/res_and_var_files/different_variables.py
Library libswithargs.Mixed ${LIST1} ${DICTIONARY1} ${None} ${42}
@@ -29,35 +32,40 @@
Library Collections
+Test Template Verify Arguments
+
***Variables***
-@{LIST WITH OBJECTS} ${None} ${1.0} ${True}
-
+@{LIST WITH OBJECTS} ${None} ${1.0} default2=not named
+${NOT NAMED} default2=d1
*** Test Cases ***
Mandatory arguments
- Verify arguments libswithargs.Mandatory first arg another arg
+ libswithargs.Mandatory first arg another arg
Default values
- Verify arguments D1 m1 value ${None}
- Verify arguments D2 m2 d1 ${None}
- Verify arguments D3 m3 ${1} ${2}
+ D1 m1 value ${None}
+ D2 m2 d1 ${None}
+ D3 m3 ${1} ${2}
+ D4 m4 value d2
+ D5 m5 default2=d1 ${None}
Varargs
- Verify arguments V1 m1 ${EMPTY}
- Verify arguments V2 m2 v1
- Verify arguments V3 m3 1 2
+ V1 m1 ${EMPTY}
+ V2 m2 v1
+ V3 m3 1 2
Mixed
- Verify arguments M1 m1 ${42} ${EMPTY}
- Verify arguments M2 m2 d1 ${EMPTY}
- Verify arguments M3 m3 d2 v
- Verify arguments M4 m4 d3 v1 v2
+ M1 m1 ${42} ${EMPTY}
+ M2 m2 d1 ${EMPTY}
+ M3 m3 d1 ${EMPTY}
+ M4 m4 d2 v
+ M5 m5 d3 v1 v2
Variables containing objects
- Verify arguments libswithargs.Mixed ${LIST1} ${DICTIONARY1} None 42
- Verify arguments libswithargs.Defaults ${None} ${1.0} ${True}
+ libswithargs.Mixed ${LIST1} ${DICTIONARY1} None 42
+ libswithargs.Defaults ${None} ${1.0} default2=not named
***Keywords***