diff options
author | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2008-09-02 10:09:25 +0200 |
---|---|---|
committer | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2008-09-02 10:09:25 +0200 |
commit | ee7381d202fa4eb3da293c625479b3ae5712e13b (patch) | |
tree | 3e02ea8005b8fa4f712fa3275a4fc2c085eb27f3 | |
parent | c1d29586611710538307bed1ac3ecaac3367f40a (diff) | |
download | logilab-common-ee7381d202fa4eb3da293c625479b3ae5712e13b.tar.gz |
test the tempdir cm
-rw-r--r-- | test/unittest_context.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unittest_context.py b/test/unittest_context.py new file mode 100644 index 0000000..418c5e4 --- /dev/null +++ b/test/unittest_context.py @@ -0,0 +1,25 @@ +from __future__ import with_statement + +import unittest +from os.path import isdir, exists + +from logilab.common.testlib import TestCase +from logilab.common.context import tempdir + +class ContextTC(TestCase): + + def test_withtempdir(self): + with tempdir() as tmpdir: + assert exists(tmpdir) + assert isdir(tmpdir) + assert not exists(tmpdir) + try: + with tempdir() as tmpdir: + assert exists(tmpdir) + raise Exception + except: + pass + assert not exists(tmpdir) + +if __name__ == '__main__': + unittest_main() |