From 9b4fcbd538179a02874007a6d85b36549e86d3c9 Mon Sep 17 00:00:00 2001 From: "willmcgugan@gmail.com" Date: Fri, 18 Oct 2013 17:33:00 +0000 Subject: Tests for getinfokeys git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@882 67cdc799-7952-0410-af00-57a81ceafa0f --- fs/tests/__init__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/tests/__init__.py b/fs/tests/__init__.py index 42f396f..86cb656 100644 --- a/fs/tests/__init__.py +++ b/fs/tests/__init__.py @@ -514,8 +514,23 @@ class FSTestCases(object): self.assertRaises( ResourceNotFoundError, self.fs.getinfo, "info.txt/inval") + def test_infokeys(self): + test_str = b("Hello, World!") + self.fs.setcontents("info.txt", test_str) + info = self.fs.getinfo("info.txt") + for k, v in info.iteritems(): + self.assertEqual(self.fs.getinfokeys('info.txt', k), {k: v}) + + test_info = {} + if 'modified_time' in info: + test_info['modified_time'] = info['modified_time'] + if 'size' in info: + test_info['size'] = info['size'] + self.assertEqual(self.fs.getinfokeys('info.txt', 'size', 'modified_time'), test_info) + self.assertEqual(self.fs.getinfokeys('info.txt', 'thiscantpossiblyexistininfo'), {}) + def test_getsize(self): - test_str = b("*")*23 + test_str = b("*") * 23 self.fs.setcontents("info.txt", test_str) size = self.fs.getsize("info.txt") self.assertEqual(size, len(test_str)) @@ -900,7 +915,7 @@ class FSTestCases(object): def test_zero_read(self): """Test read(0) returns empty string""" - self.fs.setcontents('foo.txt', b('Hello, World') ) + self.fs.setcontents('foo.txt', b('Hello, World')) with self.fs.open('foo.txt', 'rb') as f: self.assert_(len(f.read(0)) == 0) with self.fs.open('foo.txt', 'rt') as f: -- cgit v1.2.1