Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27937
| 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 | <laddosingh@gmail.com> |
| 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 | <mailman.3766.1345835099.4697.python-list@python.org> |
| 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> <roy-CDABA6.08285523082012@news.panix.com> <mailman.3724.1345742998.4697.python-list@python.org> <mailman.3728.1345748791.4697.python-list@python.org> <8447c547-8472-48c6-ad78-87989c1ce288@googlegroups.com> <mailman.3766.1345835099.4697.python-list@python.org> |
| 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 <laddosingh@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.3846.1346002565.4697.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
Thanks Rob,
I'v modified the test_3 like this:
def test_3(self):
f = open("test.dat", "wb")
filesize = (b'b'*1000000)
f.write(filesize)
f.close()
statinfo = os.stat("test.dat")
self.assertEqual(statinfo.st_size, filesize)
I'm still getting AssertionError and the error says: 1000000 !=b'
Help appreciated.
T
kl. 21:04:54 UTC+2 fredag 24. august 2012 skrev Robert Day følgende:
> 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@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.)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-23 04:25 -0700
Re: Unittest - testing for filenames and filesize Roy Smith <roy@panix.com> - 2012-08-23 08:28 -0400
Re: Unittest - testing for filenames and filesize Terry Reedy <tjreedy@udel.edu> - 2012-08-23 13:29 -0400
Re: Unittest - testing for filenames and filesize Roy Smith <roy@panix.com> - 2012-08-23 12:06 -0700
Re: Unittest - testing for filenames and filesize Roy Smith <roy@panix.com> - 2012-08-23 12:06 -0700
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-24 09:20 -0700
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-24 09:20 -0700
Re: Unittest - testing for filenames and filesize Robert Day <robertkday@gmail.com> - 2012-08-24 20:04 +0100
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-26 10:36 -0700
Re: Unittest - testing for filenames and filesize Rob Day <rkd@rkd.me.uk> - 2012-08-26 18:51 +0100
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-26 11:37 -0700
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-26 11:37 -0700
Re: Unittest - testing for filenames and filesize Tigerstyle <laddosingh@gmail.com> - 2012-08-26 10:36 -0700
Re: Unittest - testing for filenames and filesize Chris Withers <chris@python.org> - 2012-08-31 17:19 +0100
Re: Unittest - testing for filenames and filesize 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-31 22:08 -0700
Re: Unittest - testing for filenames and filesize 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-31 22:08 -0700
csiph-web