diff options
author | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2008-09-02 10:52:38 +0200 |
---|---|---|
committer | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2008-09-02 10:52:38 +0200 |
commit | 6a095482bf00005424a654d8fd3e35da4f17a08d (patch) | |
tree | afb8a5959f2535d74446544442d04e49086b1d37 | |
parent | ee7381d202fa4eb3da293c625479b3ae5712e13b (diff) | |
download | logilab-common-6a095482bf00005424a654d8fd3e35da4f17a08d.tar.gz |
* update README
* make the test python < 2.5 -proof
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | context.py | 4 | ||||
-rw-r--r-- | test/unittest_context.py | 15 |
3 files changed, 15 insertions, 7 deletions
@@ -60,6 +60,9 @@ Here is a brief description of the available modules : Two mix-in classes to handle configuration from both command line (using optik/optparse) and configuration file. +* context.py : + One context manager (python 2.5+) to handle temporary directories. + * corbautils.py: Usefull functions for use with the OmniORB CORBA library. @@ -3,9 +3,9 @@ import tempfile import shutil @contextmanager -def tempdir(): +def tempdir(ignore_error=False, onerror=None): try: path = tempfile.mkdtemp() yield path finally: - shutil.rmtree(path) + shutil.rmtree(path, ignore_error, onerror) diff --git a/test/unittest_context.py b/test/unittest_context.py index 418c5e4..74eee69 100644 --- a/test/unittest_context.py +++ b/test/unittest_context.py @@ -1,9 +1,8 @@ +TEST = """ from __future__ import with_statement - -import unittest from os.path import isdir, exists -from logilab.common.testlib import TestCase +from logilab.common.testlib import TestCase, unittest_main from logilab.common.context import tempdir class ContextTC(TestCase): @@ -20,6 +19,12 @@ class ContextTC(TestCase): except: pass assert not exists(tmpdir) - -if __name__ == '__main__': +try: unittest_main() +except SystemExit: + pass +""" + +import sys +if sys.version_info[:2] >= (2, 5): + exec(TEST) |