Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'modified': 0.05; 'bytes.': 0.07; 'f.close()': 0.07; 'python': 0.09; 'argument,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; '2.7.3': 0.16; 'wrote:': 0.17; 'working.': 0.17; '>>>': 0.18; 'import': 0.21; 'cc:2**0': 0.23; '(you': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'appreciated.': 0.26; '-0700,': 0.29; "i'm": 0.29; 'fri,': 0.30; 'function': 0.30; 'error': 0.30; 'url:python': 0.32; 'file': 0.32; 'getting': 0.33; 'skip:s 30': 0.33; 'equal': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'path': 0.35; 'robert': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'created': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'test': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'url:docs': 0.38; 'takes': 0.39; 'help': 0.40; 'is.': 0.62; 'more': 0.63; 'jul': 0.65; 'august': 0.66; 'million': 0.72; 'day': 0.73; '24.': 0.84; 'received:209.85.220.184': 0.91 Newsgroups: comp.lang.python Date: Sun, 26 Aug 2012 10:36:03 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.166.233.176; posting-account=04fc6goAAACDYxuhiIAKatXLjxcOghf2 References: <6b0299df-bc24-406b-8d69-489e990d8e4f@googlegroups.com> <8447c547-8472-48c6-ad78-87989c1ce288@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 81.166.233.176 MIME-Version: 1.0 Subject: Re: Unittest - testing for filenames and filesize From: Tigerstyle To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346002565 news.xs4all.nl 6953 [2001:888:2000:d::a6]:43404 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27937 Thanks Rob, I'v modified the test_3 like this: def test_3(self): f =3D open("test.dat", "wb") filesize =3D (b'b'*1000000) f.write(filesize) f.close() statinfo =3D os.stat("test.dat") self.assertEqual(statinfo.st_size, filesize) =20 I'm still getting AssertionError and the error says: 1000000 !=3Db' Help appreciated. T=20 kl. 21:04:54 UTC+2 fredag 24. august 2012 skrev Robert Day f=F8lgende: > On Fri, 2012-08-24 at 09:20 -0700, Tigerstyle wrote: >=20 >=20 >=20 > > def test_3(self): >=20 > > f =3D open("test.dat", "wb") >=20 > > filesize =3D b"0"*1000000 >=20 > > f.write(filesize) >=20 > > f.close() >=20 > > self.assertEqual(os.stat, filesize) >=20 >=20 >=20 > > The test_3 is to test if the created binary file har the size of 1 mill= ion bytes. Somehow it is not working. Any suggestions? >=20 > > =20 >=20 >=20 >=20 > rob@rivertam:~$ python >=20 > Python 2.7.3 (default, Jul 24 2012, 10:05:38)=20 >=20 > [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2 >=20 > Type "help", "copyright", "credits" or "license" for more information. >=20 > >>> import os >=20 > >>> os.stat >=20 > >=20 > >>>=20 >=20 >=20 >=20 > So that's what 'os.stat' is. Why are you testing whether that's equal to >=20 > b"0"*1000000? >=20 >=20 >=20 > (You may find the documentation on os.stat at >=20 > http://docs.python.org/library/os.html#os.stat helpful; it's a function >=20 > which takes a path as its argument, and returns an object with some >=20 > relevant attributes.)