summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Bicking <ian@ianbicking.org>2005-09-07 18:05:54 +0000
committerIan Bicking <ian@ianbicking.org>2005-09-07 18:05:54 +0000
commit6842b431ce8752d2e01e1aa88dc0dabd81e69a9b (patch)
treecad288135f41e9febee075ff2020a3cea7c622b9
parent6d39c32055a565713995c5af00bfd7679e6a7dcc (diff)
downloadpaste-git-6842b431ce8752d2e01e1aa88dc0dabd81e69a9b.tar.gz
Added file content assertions
-rw-r--r--paste/fixture.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/paste/fixture.py b/paste/fixture.py
index f79da67..8a1f27d 100644
--- a/paste/fixture.py
+++ b/paste/fixture.py
@@ -678,6 +678,22 @@ class FoundFile(object):
self.stat = os.stat(self.full)
self.mtime = self.stat.st_mtime
self.size = self.stat.st_size
+ self._bytes = None
+
+ def bytes__get(self):
+ if self._bytes is None:
+ f = open(self.full, 'rb')
+ self._bytes = f.read()
+ f.close()
+ return self._bytes
+ bytes = property(bytes__get)
+
+ def __contain__(self, s):
+ return s in self.bytes
+
+ def mustcontain(self, s):
+ bytes = self.bytes
+ assert s in bytes
class FoundDir(object):