Revision: 3309
Author: janne.t.harkonen
Date: Tue May 18 02:58:59 2010
Log: Get curdir from datafile source, renamed class
http://code.google.com/p/robotframework/source/detail?r=3309
Modified:
/trunk/src/robot/parsing/populator.py
/trunk/utest/parsing/test_populator.py
=======================================
--- /trunk/src/robot/parsing/populator.py Tue May 18 02:58:48 2010
+++ /trunk/src/robot/parsing/populator.py Tue May 18 02:58:59 2010
@@ -279,7 +279,7 @@
def populate(self): pass
-class TestCaseFilePopulator(Populator):
+class TestDataPopulator(Populator):
_null_populator = NullPopulator()
populators = utils.NormalizedDict({'Setting':
SettingTablePopulator,
'Settings':
SettingTablePopulator,
@@ -293,10 +293,15 @@
'User Keyword':
KeywordTablePopulator,
'User Keywords':
KeywordTablePopulator})
- def __init__(self, datafile, path):
+ def __init__(self, datafile):
self._datafile = datafile
self._current_populator = self._null_populator
- self._curdir = os.path.dirname(path)
+ self._curdir = self._determine_curdir(datafile)
+
+ def _determine_curdir(self, datafile):
+ if datafile.source:
+ return os.path.dirname(datafile.source)
+ return None
def start_table(self, name):
try:
@@ -305,11 +310,8 @@
self._current_populator = self._null_populator
return self._current_populator is not self._null_populator
- def populate(self):
- self._current_populator.populate()
-
def eof(self):
- self.populate()
+ self._current_populator.populate()
def add(self, row):
if PROCESS_CURDIR:
=======================================
--- /trunk/utest/parsing/test_populator.py Tue May 18 02:27:39 2010
+++ /trunk/utest/parsing/test_populator.py Tue May 18 02:58:59 2010
@@ -1,7 +1,7 @@
import unittest
import os
-from robot.parsing.populator import TestCaseFilePopulator
+from robot.parsing.populator import TestDataPopulator
from robot.parsing.newmodel import TestCaseFile
from robot.utils.asserts import assert_equals, assert_true, assert_false
@@ -10,8 +10,8 @@
def setUp(self):
self._datafile = TestCaseFile()
- self._path = '/path/to/source.txt'
- self._populator = TestCaseFilePopulator(self._datafile, self._path)
+ self._datafile.source = '/path/to/source.txt'
+ self._populator = TestDataPopulator(self._datafile)
def test_starting_valid_table(self):
for name in ['Test Cases', ' variables ', 'K E Y WO R D S']:
@@ -128,7 +128,6 @@
assert_equals(for_loop.vars, ['${i}'])
assert_equals(for_loop.values,
['10', '20', '30', '40', '50', '60'])
-
def test_test_settings(self):
doc = 'This is domumentation for the test case'
self._create_table('Test cases', [['My test name'],
@@ -171,7 +170,8 @@
def test_curdir_handling(self):
self._create_table('Test cases', [['My test name'],
['', 'Log', '${CURDIR}']])
- assert_equals(self._first_test().steps[0].args,
[os.path.dirname(self._path)])
+ assert_equals(self._first_test().steps[0].args,
+ [os.path.dirname(self._datafile.source)])
def test_turn_off_curdir_handling(self):
from robot.parsing import populator