- Timestamp:
- 11 Nov 2011, 10:02:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_helpers.py
r6502 r7080 27 27 import unittest 28 28 import doctest 29 from cStringIO import StringIO 29 30 from zope.security.testing import Principal, Participation 30 31 from zope.security.management import newInteraction, endInteraction … … 219 220 f2 = open(p2, 'wb').write('Ho!') 220 221 assert helpers.cmp_files(open(p1, 'r'), open(p2, 'r')) is False 222 223 class FileSizeTestCase(unittest.TestCase): 224 225 def setUp(self): 226 self.workdir = tempfile.mkdtemp() 227 228 def tearDown(self): 229 shutil.rmtree(self.workdir) 230 231 def test_real_file(self): 232 # we can get the size of real files 233 path = os.path.join(self.workdir, 'sample.txt') 234 open(path, 'wb').write('My content') 235 self.assertEqual( 236 int(helpers.file_size(open(path, 'rb'))), 10) 237 return 238 239 def test_stringio_file(self): 240 # we can get the size of file-like objects 241 self.assertEqual( 242 helpers.file_size(StringIO('my sample content')), 17) 221 243 222 244 def test_suite(): … … 230 252 CurrentPrincipalTestCase, 231 253 CmpFilesTestCase, 254 FileSizeTestCase, 232 255 ]: 233 256 suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.