Revision: 8682fd630b11
Author: Janne Härkönen <[email protected]>
Date: Wed Jan 25 01:46:49 2012
Log: tidy: added test for running tidy as a script
http://code.google.com/p/robotframework/source/detail?r=8682fd630b11
Modified:
/atest/robot/tidy/TidyLib.py
/atest/robot/tidy/tidy.txt
=======================================
--- /atest/robot/tidy/TidyLib.py Tue Jan 17 05:08:05 2012
+++ /atest/robot/tidy/TidyLib.py Wed Jan 25 01:46:49 2012
@@ -17,13 +17,15 @@
def __init__(self, interpreter):
self._cmd = [interpreter, '-m', 'robot.tidy']
+ self._interpreter = interpreter
path_var = 'PYTHONPATH' if 'python' in interpreter
else 'JYTHONPATH'
self._env = os.environ
self._env.update({path_var: ROBOT_SRC})
- def run_tidy_and_return_output(self, options, input):
+ def run_tidy_and_return_output(self, options, input, command=None):
"""Runs tidy in the operating system and returns output."""
options = options.split(' ') if options else []
+ command = command or self._cmd
with tempfile.TemporaryFile() as output:
rc = call(self._cmd + options + [self._path(input)],
stdout=output, stderr=STDOUT,
@@ -39,6 +41,12 @@
result = self.run_tidy_and_return_output(options, input)
self._assert_result(result, open(self._path(expected)).read())
+ def run_tidy_as_a_script_and_check_result(self, options, input,
expected):
+ """Runs tidy and checks that output matches content of file
`expected`."""
+ cmd = [self._interpreter, join(ROBOT_SRC, 'robot', 'tidy.py')]
+ result = self.run_tidy_and_return_output(options, input, cmd)
+ self._assert_result(result, open(self._path(expected)).read())
+
def _path(self, path):
return path.replace('/', os.sep)
=======================================
--- /atest/robot/tidy/tidy.txt Tue Jan 17 02:28:11 2012
+++ /atest/robot/tidy/tidy.txt Wed Jan 25 01:46:49 2012
@@ -64,6 +64,9 @@
Custom headers are preserved and tables aligned accordingly
Run tidy and check result ${EMPTY}
${DATADIR}/golden_with_headers.txt ${DATADIR}/golden_with_headers.txt
+Running Tidy as a script
+ Run tidy as a script and check result ${EMPTY}
${DATADIR}/golden.txt ${DATADIR}/golden.txt
+
*** Keywords ***
Run tidy with golden file and check result