Unittest - testing for filenames and filesize
Robert Day
robertkday at gmail.com
Fri Aug 24 15:04:54 EDT 2012
On Fri, 2012-08-24 at 09:20 -0700, Tigerstyle wrote:
> def test_3(self):
> f = open("test.dat", "wb")
> filesize = b"0"*1000000
> f.write(filesize)
> f.close()
> self.assertEqual(os.stat, filesize)
> The test_3 is to test if the created binary file har the size of 1 million bytes. Somehow it is not working. Any suggestions?
>
rob at rivertam:~$ python
Python 2.7.3 (default, Jul 24 2012, 10:05:38)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat
<built-in function stat>
>>>
So that's what 'os.stat' is. Why are you testing whether that's equal to
b"0"*1000000?
(You may find the documentation on os.stat at
http://docs.python.org/library/os.html#os.stat helpful; it's a function
which takes a path as its argument, and returns an object with some
relevant attributes.)
More information about the Python-list
mailing list