Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28203
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dihedral88888@googlemail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '[],': 0.07; 'f.close()': 0.07; 'filename': 0.07; 'python': 0.09; '"w")': 0.09; 'os.getcwd()': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; "wouldn't": 0.11; 'stack': 0.15; 'daemons': 0.16; 'empty"': 0.16; 'iterators': 0.16; 'paths.': 0.16; 'setup(self):': 0.16; 'simplistix': 0.16; 'url:packages': 0.16; 'url:simplistix': 0.16; 'wrote:': 0.17; 'cheers,': 0.23; 'absolute': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'supported': 0.26; 'cc:addr:gmail.com': 0.27; 'tree': 0.27; 'chris': 0.28; 'class': 0.29; 'url:python': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'received:google.com': 0.34; 'from:addr:googlemail.com': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; 'listing': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'skip:" 10': 0.40; 'services': 0.64; 'url:co': 0.66 |
| Newsgroups | comp.lang.python |
| Date | Fri, 31 Aug 2012 22:08:56 -0700 (PDT) |
| In-Reply-To | <mailman.6.1346431828.27098.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw |
| References | <6b0299df-bc24-406b-8d69-489e990d8e4f@googlegroups.com> <mailman.6.1346431828.27098.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 123.192.32.215 |
| MIME-Version | 1.0 |
| Subject | Re: Unittest - testing for filenames and filesize |
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org, Tigerstyle <laddosingh@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.23.1346476139.27098.python-list@python.org> (permalink) |
| Lines | 81 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1346476139 news.xs4all.nl 6919 [2001:888:2000:d::a6]:36760 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28203 |
Show key headers only | View raw
On Saturday, September 1, 2012 12:19:10 AM UTC+8, Chris Withers wrote:
> On 23/08/2012 12:25, Tigerstyle wrote:
>
> > class FileTest(unittest.TestCase):
>
> >
>
> > def setUp(self):
>
> > self.origdir = os.getcwd()
>
> > self.dirname = tempfile.mkdtemp("testdir")
>
> > os.chdir(self.dirname)
>
>
>
> I wouldn't change directories like this, it's pretty fragile, just use
>
> absolute paths.
>
>
>
> > def test_1(self):
>
> > "Verify creation of files is possible"
>
> > for filename in ("this.txt", "that.txt", "the_other.txt"):
>
> > f = open(filename, "w")
>
> > f.write("Some text\n")
>
> > f.close()
>
> > self.assertTrue(f.closed)
>
> >
>
> > def test_2(self):
>
> > "Verify that current directory is empty"
>
> > self.assertEqual(glob.glob("*"), [], "Directory not empty")
>
> >
>
> > def tearDown(self):
>
> > os.chdir(self.origdir)
>
> > shutil.rmtree(self.dirname)
>
>
>
> Seeing this, you might find the following tools useful:
>
>
>
> http://packages.python.org/testfixtures/files.html
>
>
>
> cheers,
>
>
>
> Chris
>
>
>
> --
>
> Simplistix - Content Management, Batch Processing & Python Consulting
>
> - http://www.simplistix.co.uk
Well, I am thinking that the directory tree listing services or daemons
supported by the OS by some iterators could be better than the stack
based model.
Back to comp.lang.python | Previous | Next — Previous 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