2 new revisions:
Revision: e89a8cb42e49
Author: Pekka Klärck
Date: Tue Jan 3 06:07:16 2012
Log: cleanup - we always have logger here nowadays
http://code.google.com/p/robotframework/source/detail?r=e89a8cb42e49
Revision: d816065043d5
Author: Pekka Klärck
Date: Tue Jan 3 06:42:40 2012
Log: import cache: only absolute paths can be normalized
http://code.google.com/p/robotframework/source/detail?r=d816065043d5
==============================================================================
Revision: e89a8cb42e49
Author: Pekka Klärck
Date: Tue Jan 3 06:07:16 2012
Log: cleanup - we always have logger here nowadays
http://code.google.com/p/robotframework/source/detail?r=e89a8cb42e49
Modified:
/src/robot/utils/importer.py
=======================================
--- /src/robot/utils/importer.py Tue Jan 3 06:03:42 2012
+++ /src/robot/utils/importer.py Tue Jan 3 06:07:16 2012
@@ -109,12 +109,11 @@
yield ' %s' % item
def _log_import_succeeded(self, item, name, source):
- if self._logger:
- import_type = '%s ' % self._type if self._type else ''
- item_type = 'module' if inspect.ismodule(item) else 'class'
- location = ("'%s'" % source) if source else 'unknown location'
- self._logger.info("Imported %s%s '%s' from %s."
- % (import_type, item_type, name, location))
+ import_type = '%s ' % self._type if self._type else ''
+ item_type = 'module' if inspect.ismodule(item) else 'class'
+ location = ("'%s'" % source) if source else 'unknown location'
+ self._logger.info("Imported %s%s '%s' from %s."
+ % (import_type, item_type, name, location))
class _Importer(object):
==============================================================================
Revision: d816065043d5
Author: Pekka Klärck
Date: Tue Jan 3 06:42:40 2012
Log: import cache: only absolute paths can be normalized
http://code.google.com/p/robotframework/source/detail?r=d816065043d5
Modified:
/src/robot/running/importer.py
/utest/running/test_importer.py
=======================================
--- /src/robot/running/importer.py Sun Jan 1 15:02:56 2012
+++ /src/robot/running/importer.py Tue Jan 3 06:42:40 2012
@@ -112,8 +112,11 @@
return self._items
def _norm_path_key(self, key):
+ if self._is_path(key):
+ return utils.normpath(key)
if isinstance(key, tuple):
return tuple(self._norm_path_key(k) for k in key)
- if isinstance(key, basestring) and os.path.exists(key):
- return utils.normpath(key)
return key
+
+ def _is_path(self, key):
+ return isinstance(key, basestring) and os.path.isabs(key) and
os.path.exists(key)
=======================================
--- /utest/running/test_importer.py Wed Sep 28 05:54:27 2011
+++ /utest/running/test_importer.py Tue Jan 3 06:42:40 2012
@@ -1,8 +1,10 @@
import unittest
+import os
+from os.path import abspath, join, normpath, normcase
from robot.running.importer import ImportCache
from robot.errors import FrameworkError
-from robot.utils.asserts import *
+from robot.utils.asserts import assert_equals, assert_true, assert_raises
class TestImportCache(unittest.TestCase):
@@ -31,8 +33,8 @@
def test_contains_item(self):
assert_true(('lib', ['a1', 'a2']) in self.cache)
assert_true('res' in self.cache)
- assert_false(('lib', ['a1', 'a2', 'wrong']) in self.cache)
- assert_false('nonex' in self.cache)
+ assert_true(('lib', ['a1', 'a2', 'wrong']) not in self.cache)
+ assert_true('nonex' not in self.cache)
def test_get_non_existing_item(self):
assert_raises(KeyError, self.cache.__getitem__, 'nonex')
@@ -41,6 +43,29 @@
def test_invalid_key(self):
assert_raises(FrameworkError, self.cache.__setitem__, ['inv'],
None)
+ def test_existing_absolute_paths_are_normalized(self):
+ cache = ImportCache()
+ path = join(abspath('.'), '.', os.listdir('.')[0])
+ value = object()
+ cache[path] = value
+ assert_equals(cache[path], value)
+ assert_equals(cache._keys[0], normcase(normpath(path)))
+
+ def test_existing_non_absolute_paths_are_not_normalized(self):
+ cache = ImportCache()
+ path = os.listdir('.')[0]
+ value = object()
+ cache[path] = value
+ assert_equals(cache[path], value)
+ assert_equals(cache._keys[0], path)
+
+ def test_non_existing_absolute_paths_are_not_normalized(self):
+ cache = ImportCache()
+ path = join(abspath('.'), '.', 'NonExisting.file')
+ value = object()
+ cache[path] = value
+ assert_equals(cache[path], value)
+ assert_equals(cache._keys[0], path)
if __name__ == '__main__':
unittest.main()