Revision: 3595
Author: pekka.klarck
Date: Thu May 27 11:12:49 2010
Log: removed type_as_str usages
http://code.google.com/p/robotframework/source/detail?r=3595
Modified:
/trunk/atest/robot/core/resource_and_variable_imports.txt
/trunk/atest/testdata/core/for.txt
/trunk/atest/testdata/keywords/return_values.txt
/trunk/src/robot/running/keywords.py
/trunk/src/robot/utils/importing.py
/trunk/src/robot/variables/variables.py
=======================================
--- /trunk/atest/robot/core/resource_and_variable_imports.txt Wed May 26
07:37:22 2010
+++ /trunk/atest/robot/core/resource_and_variable_imports.txt Thu May 27
11:12:49 2010
@@ -43,7 +43,7 @@
Invalid Dynamic Variable File Usage
${path} = Join Path ${RESDIR} dynamic_variables.py
- My Check Stderr Contains [ ERROR ] Invalid syntax in
file '${DATAPATH}' in table 'Setting': Processing variable file '${path}'
with arguments [ Two args returns None | which is invalid ] failed:
get_variables returned 'NoneType', expected a mapping
+ My Check Stderr Contains [ ERROR ] Invalid syntax in
file '${DATAPATH}' in table 'Setting': Processing variable file '${path}'
with arguments [ Two args returns None | which is invalid ] failed:
Expected mapping but get_variables returned NoneType.
My Check Stderr Contains [ ERROR ] Invalid syntax in
file '${DATAPATH}' in table 'Setting': Processing variable file '${path}'
with arguments [ More args raises an exception | which is invalid | of
course ] failed: Invalid arguments for get_variables
${path} = Join Path ${RESDIR} dynamicVariables.py
My Check Stderr Contains [ ERROR ] Invalid syntax in
file '${DATAPATH}' in table 'Setting': Replacing variables from
setting 'Variables' failed: Non-existing
variable '\${non_existing_var_as_arg}'
=======================================
--- /trunk/atest/testdata/core/for.txt Thu May 27 03:45:40 2010
+++ /trunk/atest/testdata/core/for.txt Thu May 27 11:12:49 2010
@@ -184,7 +184,7 @@
\ Log ${nonexisting}
For With Invalid Set
- [Documentation] FAIL Cannot assign return values: Expected list-like
object, got string instead.
+ [Documentation] FAIL Cannot assign return values: Expected list-like
object, got unicode instead.
:FOR ${i} IN 1 3
\ ${x} ${y} = Set Variable Only one value
=======================================
--- /trunk/atest/testdata/keywords/return_values.txt Wed May 26 02:48:14
2010
+++ /trunk/atest/testdata/keywords/return_values.txt Thu May 27 11:12:49
2010
@@ -95,11 +95,11 @@
${a} ${b} ${c} = Create List a b
Multiple Scalars When No List Returned
- [Documentation] FAIL Cannot assign return values: Expected list-like
object, got string instead.
+ [Documentation] FAIL Cannot assign return values: Expected list-like
object, got unicode instead.
${a} ${b} = Set Variable This is not list
List When No List Returned
- [Documentation] FAIL Cannot assign return values: Expected list-like
object, got integer instead.
+ [Documentation] FAIL Cannot assign return values: Expected list-like
object, got long instead.
@{list} = Set Variable ${42}
List To Scalar And List Varibles
=======================================
--- /trunk/src/robot/running/keywords.py Thu May 27 07:11:21 2010
+++ /trunk/src/robot/running/keywords.py Thu May 27 11:12:49 2010
@@ -210,7 +210,7 @@
def _raise_invalid_return_value(self, ret, wrong_type=False):
if wrong_type:
err = 'Expected list-like object, got %s instead' \
- % utils.type_as_str(ret, True)
+ % type(ret).__name__
else:
err = 'Need more values than %d' % len(ret)
raise DataError("Cannot assign return values: %s." % err)
=======================================
--- /trunk/src/robot/utils/importing.py Wed May 12 06:09:52 2010
+++ /trunk/src/robot/utils/importing.py Thu May 27 11:12:49 2010
@@ -15,13 +15,10 @@
import os
import sys
-from types import ModuleType, ClassType, TypeType
-if sys.platform.startswith('java'):
- from java.lang import System
+import inspect
from robot.errors import DataError
from error import get_error_message, get_error_details
-from robottypes import type_as_str
from normalizing import normpath
@@ -104,7 +101,7 @@
if fromlist:
_raise_no_lib_in_module(type_, modname, fromlist[0])
code = imported
- if not isinstance(code, (ModuleType, ClassType, TypeType)):
+ if inspect.ismodule(code):
if fromlist:
_raise_invalid_type(type_, code)
else:
@@ -136,13 +133,14 @@
msg = ["Importing %s '%s' failed: %s" % (type_, name, error_msg),
"PYTHONPATH: %s" % sys.path, error_details]
if sys.platform.startswith('java'):
+ from java.lang import System
msg.insert(-1, 'CLASSPATH: %s' %
System.getProperty('java.class.path'))
raise DataError('\n'.join(msg))
def _raise_no_lib_in_module(type_, modname, libname):
- raise DataError("%s module '%s' does not contain '%s'"
+ raise DataError("%s module '%s' does not contain '%s'."
% (type_.capitalize(), modname, libname))
def _raise_invalid_type(type_, code):
- raise DataError("Imported %s is not a class or module, got '%s'
instead"
- % (type_, type_as_str(code)))
+ raise DataError("Imported %s should be a class or module, got %s."
+ % (type_, type(code).__name__))
=======================================
--- /trunk/src/robot/variables/variables.py Thu May 27 07:11:21 2010
+++ /trunk/src/robot/variables/variables.py Thu May 27 11:12:49 2010
@@ -297,9 +297,8 @@
return variables.items()
if isinstance(variables, Map):
return [(entry.key, entry.value) for entry in
variables.entrySet()]
- raise DataError("%s returned '%s', expected a mapping"
- % (get_variables.__name__,
- utils.type_as_str(variables)))
+ raise DataError("Expected mapping but %s returned %s."
+ % (get_variables.__name__,
type(variables).__name__))
def has_key(self, key):
try: