From 59468a2002aa26808a83fd2fb2db0e4e2c83575f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 12 Apr 2012 20:59:05 +0100 Subject: Move cat method to cmdtestlib --- cmdtest | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'cmdtest') 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 = { -- cgit v1.2.1