summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@logilab.fr>2008-06-27 16:22:10 +0200
committerPierre-Yves David <pierre-yves.david@logilab.fr>2008-06-27 16:22:10 +0200
commit8bc19ba9563bb934f57767e27a6f243aa27fdf20 (patch)
tree6e10f195df6d0be0a9d9e6851b3cbf214c1f662c
parent9c2bba4cc83f9ca438d409370b4bc4b5083f363c (diff)
downloadlogilab-common-8bc19ba9563bb934f57767e27a6f243aa27fdf20.tar.gz
add a with_tempdir decorator ensuring all temporary files and dirs are removed
-rw-r--r--ChangeLog333
-rw-r--r--test/unittest_testlib.py64
-rw-r--r--testlib.py21
3 files changed, 418 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d974a41..af370f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,100 +4,164 @@ ChangeLog for logilab.common
--
* changelog propertly adds new line at the end of each entry
+ * add a with_tempdir decorator ensuring all temporary files and dirs are removed
+
+
+
2008-06-25 -- 0.33.0
* decorators: new @locked decorator
+
* cache: make it thread safe, changed behaviour so that when cache size is 0
and __delitem__ is called, a KeyError is raised (more consistent)
+
* testlib:
- added assertIsNot, assertNone and assertNotNone assertion
- added assertUnorderedIterableEquals
- added assertDirEquals
- various failure ouput improvement
+
* umessage: umessage.date() mayreturn unparsage string as is instead of None
+
* compat: adds a max function taking 'key' as keyword argument as in 2.5
+
* configuration: escape rest when printing for default value
+
+
2008-06-08 -- 0.32.0
* textutils: add the apply_unit fonction
+
* testlib:
- added a assertXMLEqualsTuple test assertion
- added a assertIs assertion
+
+
2008-05-08 -- 0.31.0
* improved documentation and error messages
+
* testlib: support a msg argument on more assertions, pysqlite2 as default
+
* pytest: pytestconf.py for customization
+
+
2008-03-26 -- 0.30.0
* db: remember logged user on the connection
+
* clcommands: commands may be hidden (eg not displayed in help), generic
ListCommandsCommand useful to build bash completion helpers
+
* changelog: module to parse ChangeLog file as this one, backported from
logilab.devtools
+
+
2008-03-12 -- 0.29.1
* date: new nb_open_days function counting worked days between two date
+
* adbh: add -p option to mysql commands to ask for password
+
+
2008-03-05 -- 0.29.0
* adbh: mysql doesn't support ILIKE, implement list_indices for mysql
+
* db: mysql adapter use mx DateTime when available, fix unicode handling
+
+
2008-02-18 -- 0.28.2
* testlib: restore python2.3 compatiblity
+
+
2008-02-15 -- 0.28.1
* testlib: introduce InnerTest class to name generative tests, fix
generative tests description storage
+
* pytest: fix -s option
+
* modutils: included Stefan Rank's patch to deal with 2.4 relative import
+
* configuration: don't give option's keywords not recognized by optparse,
fix merge_options function
+
+
2008-02-05 -- 0.28.0
* date: new `add_days_worked` function
+
* shellutils: new `chown` function
+
* testlib: new `strict` argument to assertIsInstance
+
* __init__: new `attrdict` and `nullobject` classes
+
+
2008-01-25 -- 0.27.0
* deprecation: new class_moved utility function
+
* interface: fix subinterface handling
+
+
2008-01-10 -- 0.26.1
* optparser: support --version at main command level
+
* testlib: added man page for pytest
+
* textutils: fix a bug in normalize{_,_rest_}paragraph which may cause
infinite loop if an indent string containing some spaces is given
+
+
2008-01-07 -- 0.26.0
* db: binarywrap support
+
* modutils: new LazyObject class
+
+
2007-12-20 -- 0.25.2
* adbh: new needs_from_clause variable on db helper
+
+
2007-12-11 -- 0.25.1
* pytest: new --profile option, setup module / teardown module hook,
other fixes and enhancements
+
* db: mysql support fixes
+
* adbh: fix postgres list_indices implementation
+
+
2007-11-26 -- 0.25.0
* adbh:
- list_tables implementation for sqlite
- new list_indices, create_index, drop_index methods
+
* restore python < 2.4 compat
+
+
2007-10-29 -- 0.24.0
* decorators: new classproperty decorator
+
* adbh: new module containing advanced db helper which were in the "db"
module, with additional registered procedures handling
+
+
2007-10-23 -- 0.23.1
* modutils: fix load_module_from_* (even with use_sys=False, it should
try to get outer packages from sys.modules)
+
+
2007-10-17 -- 0.23.0
* db:
- mark support_users and support_groups methods as obsolete in
@@ -105,109 +169,174 @@ ChangeLog for logilab.common
- new ilike_support property on dbms helpers
- extended db helper api
- completed mysql support
+
* textutils: new unormalize function to normalize diacritical chars by
their ascii equivalent
+
* modutils: new load_module_from_file shortcut function
+
* clcommands: pop_args accept None as value for expected_size_after,
meaning remaining args should not be checked
+
* interface: new extend function to dynamically add an implemented interface
to a new style class
+
+
2007-06-25 -- 0.22.2
* new 'typechanged' action for configuration.read_old_config
+
+
2007-05-14 -- 0.22.1
* important bug fix in db.py
+
* added history in pytest debugger sessions
+
* fix pytest coverage bug
+
* fix textutils test
+
* fix a bug which provoqued a crash if devtools was not installed
+
+
2007-05-14 -- 0.22.0
* pytest improvements
+
* shellutils: use shutil.move instead of os.rename as default action
of mv
+
* db: new `list_users` and `sql_drop_unique_constraint` methods on
advanced helpers
+
* deprecation: new `obsolete` decorator
+
+
2007-02-12 -- 0.21.3
* fixed cached decorator to use __dict__ instead of attribute lookup,
avoiding potential bugs with inheritance when using cached class
methods
+
+
2007-02-05 -- 0.21.2
* fix ReST normalization (#3471)
+
+
2006-12-19 -- 0.21.1
* tree: make Node iterable (iter on its children)
+
* configuration: fix #3197 (OptionsManagerMixin __init__ isn't passing
correctly its "version" argument)
+
* textutils: new 'rest' argument to normalize_text to better deal with
ReST formated text
+
* some packaging fixes
+
+
2006-11-14 -- 0.21.0
* db:
- new optional keepownership argument to backup|restore_database methods
- only register mxDatetime converters on psycopg2 adapter if
mx.DateTime is available
+
* moved some stuff which was in common __init__ file into specific
module. At this occasion new "decorators" and "deprecation" modules
has been added
+
* deprecated fileutils.[files_by_ext,include_files_by_ext,exclude_files_by_ext]
functions in favor of new function shellutils.find
+
* mark the following modules for deprecation, they will be removed in a
near version:
+
* astutils: moved to astng
+
* bind (never been used)
+
* html: deprecated
+
* logger/logservice: use logging module
+
* monclient/monserver (not used anymore)
+
* patricia (never been used)
+
* twisted_distutils (not used anymore)
+
* removed the following functions/methods which have been deprecated for a
while now:
+
* modutils.load_module_from_parts
+
* textutils.searchall
+
* tree.Node.leafs
+
* fileutils.get_by_ext, filetutils.get_mode, fileutils.ensure_mode
+
* umessage: more robust charset handling
+
+
2006-11-03 -- 0.20.2
* fileutils: new remove_dead_links function
+
* date: add missing strptime import
+
+
2006-11-01 -- 0.20.1
* umessage:
- new message_from_string function
- fixed get_payload encoding bug
+
* db: default postgres module is now psycopg2, which has been customized
to return mx.Datetime objects for date/time related types
+
+
2006-10-27 -- 0.20.0
* db:
- fixed date handling
- new methods on advanced helper to generate backup commands
+
* configuration: basic deprecated config handling support
+
* new implementation of pytest
+
* backport a dot backend from yams into a new "graph" module
+
+
2006-10-03 -- 0.19.3
* fixed bug in textutils.normalise_[text|paragraph] with unsplitable
word larger than the maximum line size
+
* added pytest.bat for windows installation
+
* changed configuration.generate_config to include None values into the
generated file
+
+
2006-09-25 -- 0.19.2
* testlib:
- fixed a bug in find_test making it returns some bad test names
- new assertIsInstance method on TestCase
+
* optik_ext: make it works if mx.DateTime is not installed, in which case
the date type option won't be available
+
* test fixes
+
+
2006-09-22 -- 0.19.1
* db:
- fixed bug when querying boolean on sqlite using python's bool type
@@ -215,149 +344,233 @@ ChangeLog for logilab.common
- added "drop_on_commit" argument to create_temporary_table on db helper
- added missing implementation of executemany on pysqlite2 wrapper to
support pyargs correctly like execute
+
* optik_ext: fixed "named" type option to support csv values and to return
a dictionary
+
+
2006-09-05 -- 0.19.0
* new umessage module which provides a class similar to the standard
email.Message class but returning unicode strings
+
* new clcommands module to handle commands based command line tool
(based on the configuration module)
+
* new "date" otion type in optik_ext
+
* new AttrObject in testlib to create objects in test with arbitrary attributes
+
* add pytest to run project's tests and get rid of all runtests.py
+
* add pytest option to enable design-by-contract using aspects
+
* some enhancements to the configuration module
+
+
2006-08-09 -- 0.18.0
* added -c / --capture option to testlib.unittest_main
+
* fixed bugs in lgc.configuration
+
* optparser: added a OptionParser that extends optparse's with commands
+
+
2006-07-13 -- 0.17.0
* python2.5 compatibility (testlib.py + compat.py)
+
* testlib.assertListEquals return all errors at once
+
* new "password" option type in optik_ext
+
* configuration: refactored to support interactive input of a configuration
+
+
2006-06-08 -- 0.16.1
* testlib: improved test collections
+
* compat: added cmp argument to sorted
+
+
2006-05-19 -- 0.16.0
* testlib:
- added a set of command line options (PYDEBUG is deprecated,
use the -i/--pdb option, and added -x/--exitfirst option)
- added support for generative tests
+
* db:
- fix get_connection parameter order and host/port handling
- added .sql_temporary_table method to advanced func helpers
- started a psycopg2 adapter
+
* configuration: enhanced to handle default value in help and man pages
generation (require python >= 2.4)
+
+
2006-04-25 -- 0.15.1
* db: add missing port handling to get_connection function and
dbapimodule.connect methods
+
* testlib: various fixes and minor improvments
+
+
2006-03-28 -- 0.15.0
* added "cached" decorator and a simple text progression bar into __init__
+
* added a simple text progress bar into __init__
+
* configuration: fixed man page generation when using python 2.4
+
* db: added pysqllite2 support, preconfigured to handle timestamp using
mxDatetime and to correctly handle boolean types
+
+
2006-03-06 -- 0.14.1
* backported file support and add LOG_CRIT to builtin in logservice module
+
+
2006-02-28 -- 0.14.0
* renamed assertXML*Valid to assertXML*WellFormed and deprecated the old name
+
* fixed modutils.load_module_from_*
+
+
2006-02-03 -- 0.13.1
* fix some tests, patch contributed by Marien Zwart
+
* added ability to log into a file with make_logger()
+
+
2006-01-06 -- 0.13.0
* testlib: ability to skip a test
+
* configuration:
- cleaner configuration file generation
- refactoring so that we can have more control on file
configuration loading using read_config_file and load_config_file
instead of load_file_configuration
+
* modutils: fix is_relative to return False when from_file is a file
located somewhere in sys.path
+
* ureport: new "escaped" attribute on Text nodes, controling html escaping
+
* compat: make set iterable and support more other set operations...
+
* removed the astng sub-package, since it's now self-distributed as
logilab-astng
+
+
2005-09-06 -- 0.12.0
* shellutils: bug fix in mv()
+
* compat:
- use set when available
- added sorted and reversed
+
* table: new methods and some optimizations
+
* tree: added some deprecation warnings
+
+
2005-07-25 -- 0.11.0
* db: refactoring, added sqlite support, new helpers to support DBMS
specific features
+
+
2005-07-07 -- 0.10.1
* configuration: added basic man page generation feature
+
* ureports: unicode handling, some minor fixes
+
* testlib: enhance MockConnection
+
* python2.2 related fixes in configuration and astng
+
+
2005-05-04 -- 0.10.0
* astng: improve unit tests coverage
+
* astng.astng: fix Function.format_args, new method
Function.default_value, bug fix in Node.resolve
+
* astng.builder: handle classmethod and staticmethod as decorator,
handle data descriptors when building from living objects
+
* ureports:
- new docbook formatter
- handle ReST like urls in the text writer
- new build_summary utility function
+
+
2005-04-14 -- 0.9.3
* optik_ext: add man page generation based on optik/optparse options
definition
+
* modutils: new arguments to get_source_file to handle files without
extensions
+
* astng: fix problem with the manager and python 2.2 (optik related)
+
+
2005-02-16 -- 0.9.2
* textutils:
- added epydoc documentation
- new sep argument to the get_csv function
- fix pb with normalize_* functions on windows platforms
+
* fileutils:
- added epydoc documentation
- fixed bug in get_by_ext (renamed files_by_ext) with the
exclude_dirs argument
+
* configuration:
- fixed a bug in configuration file generation on windows platforms
- better test coverage
+
* fixed testlib.DocTest which wasn't working anymore with recent
versions of pyunit
+
* added "context_file" argument to file_from_modpath to avoid
possible relative import problems
+
* astng: use the new context_file argument from Node.resolve()
+
+
2005-02-04 -- 0.9.1
* astng:
- remove buggy print
- fixed builder to deal with builtin methods
- fixed raw_building.build_function with python 2.4
+
* modutils: code cleanup, some reimplementation based on "imp",
better handling of windows specific extensions, epydoc documentation
+
* fileutils: new exclude_dirs argument to the get_by_ext function
+
* testlib: main() support -p option to run test in a profiled mode
+
* generated documentation for modutils in the doc/ subdirectory
+
+
2005-01-20 -- 0.9.0
* astng:
- refactoring of some huge methods
@@ -370,25 +583,36 @@ ChangeLog for logilab.common
building instead of exec'ing the statement
- fix possible AttributeError with Function.type
- manager.astng_from_file fallback to astng_from_module if possible
+
* textutils: fix bug in normalize_paragraph, unquote handle empty string
correctly
+
* modutils:
- use a cache in has_module to speed up things when heavily used
- fix file_from_modpath to handle pyxml and os.path
+
* configuration: fix problem with serialization/deserialization of empty
string
+
+
2005-01-04 -- 0.8.0
* modutils: a lot of fixes/rewrite on various functions to avoid
unnecessary imports, sys.path pollution, and other bugs (notably
making plylint reporting wrong modules name/path)
+
* astng: new "inspector" module, initially taken from pyreverse code
(http://www.logilab.org/projects/pyreverse), miscellaneous bug fixes
+
* configuration: new 'usage' parameter on the Configuration
initializer
+
* logger: unicode support
+
* fileutils: get_by_ext also ignore ".svn" directories, not only "CVS"
+
+
2004-11-03 -- 0.7.1
* astng:
- don't raise a syntax error on files missing a trailing \n.
@@ -396,165 +620,274 @@ ChangeLog for logilab.common
string exception was raised).
- fix utils.get_implemented.
- fix file based manager's cache problem.
+
* textutils: fixed normalize_text / normalize_paragraph functions
+
+
2004-10-11 -- 0.7.0
* astng: new methods on the manager, returning astng with nodes for
packages (ie recursive structure instead of the flat one), with
automatic lazy loading + introduction of a dict like interface to
manipulate those nodes and Module, Class and Function nodes.
+
* logservice: module imported from the ginco project
+
* configuration: added new classes Configuration and
OptionsManager2Configuration adapter, fix bug in loading options
from file
+
* optik_ext/configuration: some new option type "multiple_choice"
+
* fileutils: new ensure_mode function
+
* compat: support for sum and enumerate
+
+
2004-09-23 -- 0.6.0
* db: added DBAPIAdapter
+
* textutils: fix in pretty_match causing malformated messages in pylint
added ansi colorization management
+
* modutils: new functions get_module_files, has_module and file_from_modpath
+
* astng: some new utility functions taken from pylint, minor changes to the
manager API, Node.resolve doesn't support anymore "living" resolution,
some new methods on astng nodes
+
* compat: new module for a transparent compatibility layer between
different python version (actually 2.2 vs 2.3 for now)
+
+
2004-07-08 -- 0.5.2
* astng: fix another bug in klassnode.ancestors() method...
+
* db: fix mysql access
+
* cli: added a space after the prompt
+
+
2004-06-04 -- 0.5.1
* astng: fix undefined var bug in klassnode.ancestors() method
+
* ureports: fix attributes on title layout
+
* packaging:fix the setup.py script to allow bdist_winst (well, the
generated installer has not been tested...) with the necessary
logilab/__init__.py file
+
+
2004-05-10 -- 0.5.0
* ureports: new Universal Reports sub-package
+
* xmlrpcutils: new xmlrpc utilities module
+
* astng: resolve(name) now handle (at least try) builtins
+
* astng: fixed Class.as_string (empty paren when no base classes)
+
* astng.builder: knows a litle about method descriptors, Functin with
unknown arguments have argnames==None.
+
* fileutils: new is_binary(filename) function
+
* textutils: fixed some Windows bug
+
* tree: base not doesn't have the "title" attribute anymore
+
* testlib: removed the spawn function (who used that ?!), added MockSMTP,
MockConfigParser, MockConnexion and DocTestCase (test class for
modules embeding doctest). All mocks objects are very basic and will be
enhanced as the need comes.
+
* testlib: added a TestCase class with some additional methods then
the regular unittest.TestCase class
+
* cli: allow specifying a command prefix by a class attributes,more
robust, print available commands on help
+
* db: new "binary" function to get the binary wrapper for a given driver,
and new "system_database" function returning the system database name
for different DBMS.
+
* configuration: better group control
+
+
2004-02-20 -- 0.4.5
* db: it's now possible to fix the modules search order. By default call
set_isolation_level if psycopg is used
+
+
2004-02-17 -- 0.4.4
* modutils: special case for os.path in get_module_part
+
* astng: handle special case where we are on a package node importing a module
using the same name as the package, which may end in an infinite loop
on relative imports in Node.resolve
+
* fileutils: new get_by_ext function
+
+
2004-02-11 -- 0.4.3
* astng: refactoring of Class.ancestor_for_* methods (now
depends on python 2.2 generators)
+
* astng: make it more robust
+
* configuration: more explicit exception when a bad option is
provided
+
* configuration: define a short version of an option using the "short"
keyword, taking a single letter as value
+
* configuration: new method global_set_option on the manager
+
* testlib : allow no "suite" nor "Run" function in test modules
+
* shellutils: fix bug in *mv*
+
+
2003-12-23 -- 0.4.2
* added Project class and some new methods to the ASTNGManger
+
* some new functions in astng.utils
+
* fixed bugs in some as_string methods
+
* fixed bug in textutils.get_csv
+
* fileutils.lines now take a "comments" argument, allowing to ignore
comment lines
+
+
2003-11-24 -- 0.4.1
* added missing as_string methods on astng nodes
+
* bug fixes on Node.resolve
+
* minor fixes in textutils and fileutils
+
* better test coverage (need more !)
+
+
2003-11-13 -- 0.4.0
* new textutils and shellutils modules
+
* full astng rewrite, now based on the compiler.ast package from the
standard library
+
* added next_sbling and previous_sibling methods to Node
+
* fix get_cycles
+
+
2003-10-14 -- 0.3.5
* fixed null size cache bug
+
* added 'sort_by_column*' methods for tables
+
+
2003-10-08 -- 0.3.4
* fix bug in asntg, occuring with python2.3 and modules including an
encoding declaration
+
* fix bug in astutils.get_rhs_consumed_names, occuring in lists
comprehension
+
* remove debug print statement from configuration.py which caused a
generation of incorrect configuration files.
+
+
2003-10-01 -- 0.3.3
* fix bug in modutils.modpath_from_file
+
* new module corbautils
+
+
2003-09-18 -- 0.3.2
* fix bug in modutils.load_module_from_parts
+
* add missing __future__ imports
+
+
2003-09-18 -- 0.3.1
* change implementation of modutils.load_module_from_name (use find_module
and load_module instead of __import__)
+
* more bug fixes in astng
+
* new functions in fileutils (lines, export) and __init__ (Execute)
+
+
2003-09-12 -- 0.3
* expect "def suite" or "def Run(runner=None)" on unittest module
+
* fixes in modutils
+
* major fixes in astng
+
* new fileutils and astutils modules
+
* enhancement of the configuration module
+
* new option type "named" in optik_the ext module
+
+
2003-06-18 -- 0.2.2
* astng bug fixes
+
+
2003-06-04 -- 0.2.1
* bug fixes
+
* fix packaging problem
+
+
2003-06-02 -- 0.2.0
* add the interface, modutils, optik_ext and configuration modules
+
* add the astng sub-package
+
* miscellaneous fixes
+
+
2003-04-17 -- 0.1.2
* add the stringio module
+
* minor fixes
+
+
2003-02-28 -- 0.1.1
* fix bug in tree.py
+
* new file distutils_twisted
+
+
2003-02-17 -- 0.1.0
* initial revision
+
+
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py
index ca47fae..d6a0e9c 100644
--- a/test/unittest_testlib.py
+++ b/test/unittest_testlib.py
@@ -20,6 +20,7 @@ except NameError:
from logilab.common.testlib import TestCase, TestSuite, SkipAwareTextTestRunner
from logilab.common.testlib import mock_object, NonStrictTestLoader, create_files
from logilab.common.testlib import capture_stdout, unittest_main, InnerTest
+from logilab.common.testlib import with_tempdir
class MockTestCase(TestCase):
def __init__(self):
@@ -586,6 +587,69 @@ class OutErrCaptureTC(TestCase):
self.assertEquals(output.restore(), "hello")
+class DecoratorTC(TestCase):
+
+ @with_tempdir
+ def test_tmp_dir_normal(self):
+
+
+ tempdir = tempfile.gettempdir()
+ # assert temp directory is empty
+ self.assertListEquals(list(os.walk(tempdir)),
+ [(tempdir,[],[])])
+
+ witness = []
+
+ @with_tempdir
+ def createfile(list):
+ tempfile.mkstemp()
+ tempfile.mkstemp()
+ dir = tempfile.mkdtemp()
+ tempfile.mkstemp(dir=dir)
+ tempfile.mkdtemp()
+ list.append(True)
+
+ self.assertFalse(witness)
+ createfile(witness)
+ self.assertTrue(witness)
+
+ self.assertEquals(tempfile.gettempdir(), tempdir)
+
+ # assert temp directory is empty
+ self.assertListEquals(list(os.walk(tempdir)),
+ [(tempdir,[],[])])
+
+ @with_tempdir
+ def test_tmp_dir_normal(self):
+
+ tempdir = tempfile.gettempdir()
+ # assert temp directory is empty
+ self.assertListEquals(list(os.walk(tempfile.tempdir)),
+ [(tempfile.tempdir,[],[])])
+
+
+ class WitnessException(Exception):
+ pass
+
+ @with_tempdir
+ def createfile():
+ tempfile.mkstemp()
+ tempfile.mkstemp()
+ dir = tempfile.mkdtemp()
+ tempfile.mkstemp(dir=dir)
+ tempfile.mkdtemp()
+ raise WitnessException()
+
+ self.assertRaises(WitnessException, createfile)
+
+
+ # assert tempdir didn't change
+ self.assertEquals(tempfile.gettempdir(), tempdir)
+
+ # assert temp directory is empty
+ self.assertListEquals(list(os.walk(tempdir)),
+ [(tempdir,[],[])])
+
if __name__ == '__main__':
unittest_main()
diff --git a/testlib.py b/testlib.py
index d95bdd1..b91a297 100644
--- a/testlib.py
+++ b/testlib.py
@@ -33,11 +33,14 @@ import traceback
import unittest
import difflib
import types
+import tempfile
+from shutil import rmtree
from operator import itemgetter
from warnings import warn
from compiler.consts import CO_GENERATOR
from ConfigParser import ConfigParser
+
# PRINT_ = file('stdout.txt', 'w').write
try:
@@ -65,6 +68,24 @@ DEFAULT_PREFIXES = ('test', 'regrtest', 'smoketest', 'unittest',
ENABLE_DBC = False
+
+def with_tempdir(callable):
+ """A decorator ensuring no temporary file left when the function return
+ Work only for temporary file create with the tempfile module"""
+ def proxy(*args, **kargs):
+
+ old_tmpdir = tempfile.gettempdir()
+ new_tmpdir = tempfile.mkdtemp("-logilab-common-testlib","temp-dir-")
+ tempfile.tempdir = new_tmpdir
+ try:
+ return callable(*args, **kargs)
+ finally:
+ try:
+ rmtree(new_tmpdir, ignore_errors=True)
+ finally:
+ tempfile.tempdir = old_tmpdir
+ return proxy
+
def main(testdir=None, exitafter=True):
"""Execute a test suite.