summaryrefslogtreecommitdiff
path: root/cmdtest
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-04-12 20:59:05 +0100
committerLars Wirzenius <liw@liw.fi>2012-04-12 20:59:05 +0100
commit59468a2002aa26808a83fd2fb2db0e4e2c83575f (patch)
tree14c6d40184d6b2996d8adb368b2e2aef2f8f5bda /cmdtest
parentd340738d97b7dbc2b0a0a30d05c68e85cc6033b5 (diff)
downloadcmdtest-59468a2002aa26808a83fd2fb2db0e4e2c83575f.tar.gz
Move cat method to cmdtestlib
Diffstat (limited to 'cmdtest')
-rwxr-xr-xcmdtest12
1 files changed, 3 insertions, 9 deletions
diff --git a/cmdtest b/cmdtest
index 42927e3..02cffcf 100755
--- a/cmdtest
+++ b/cmdtest
@@ -190,7 +190,8 @@ class CommandTester(cliapp.Application):
if stderr_diff:
errors.append(TestFailure(test, 'stderr diff:\n%s' % stderr_diff))
- expected_exit = int(self.cat(test.exit or '/dev/null').strip() or '0')
+ contents = cmdtestlib.cat(test.exit or '/dev/null')
+ expected_exit = int(contents.strip() or '0')
if exit != expected_exit:
errors.append(TestFailure(test,
'got exit code %s, expected %s' %
@@ -204,15 +205,8 @@ class CommandTester(cliapp.Application):
return errors
- def cat(self, filename):
- if os.path.exists(filename):
- with open(filename) as f:
- return f.read()
- else:
- return ''
-
def lines(self, filename):
- return self.cat(filename).splitlines()
+ return cmdtestlib.cat(filename).splitlines()
def expand(self, strings):
variables = {