Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28202
| Received | by 10.66.74.225 with SMTP id x1mr2123317pav.45.1346476136805; Fri, 31 Aug 2012 22:08:56 -0700 (PDT) |
|---|---|
| Received | by 10.68.233.130 with SMTP id tw2mr2305115pbc.12.1346476136790; Fri, 31 Aug 2012 22:08:56 -0700 (PDT) |
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!news.snarked.org!newsfeed.news.ucla.edu!usenet.stanford.edu!4no1505471pbn.1!news-out.google.com!a8ni4189115pbd.1!nntp.google.com!r4no1620991pbs.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| 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 |
| NNTP-Posting-Host | 123.192.32.215 |
| References | <6b0299df-bc24-406b-8d69-489e990d8e4f@googlegroups.com> <mailman.6.1346431828.27098.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <eb40fee2-685d-45e6-9ce2-04269fa80970@googlegroups.com> (permalink) |
| Subject | Re: Unittest - testing for filenames and filesize |
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
| Cc | Tigerstyle <laddosingh@gmail.com>, python-list@python.org |
| Injection-Date | Sat, 01 Sep 2012 05:08:56 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:28202 |
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 | 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