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 --- cmdtestlib.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cmdtestlib.py') diff --git a/cmdtestlib.py b/cmdtestlib.py index 59a3879..460ab16 100644 --- a/cmdtestlib.py +++ b/cmdtestlib.py @@ -20,6 +20,15 @@ __version__ = '0.3' import os +def cat(filename): + '''Return contents of file, or empty string if it doesn't exist.''' + if os.path.exists(filename): + with open(filename) as f: + return f.read() + else: + return '' + + class TestCase(object): def __init__(self, name, path_prefix): -- cgit v1.2.1