2 from contextlib import contextmanager
3 from os.path import basename, dirname, realpath
4 from traceback import extract_stack
5 import subprocess, sys, tempfile
7 from wvtest import WVPASSEQ, wvfailure_count
9 from bup import helpers
13 def no_lingering_errors():
15 if helpers.saved_errors:
17 src_file, src_line, src_func, src_txt = bt[-4]
18 msg = 'saved_errors ' + repr(helpers.saved_errors)
19 print '! %-70s %s' % ('%s:%-4d %s' % (basename(src_file),
25 helpers.clear_errors()
28 helpers.clear_errors()
31 # Assumes (of course) this file is at the top-level of the source tree
32 _bup_tmp = realpath(dirname(__file__) + '/t/tmp')
33 helpers.mkdirp(_bup_tmp)
37 def test_tempdir(prefix):
38 initial_failures = wvfailure_count()
39 tmpdir = tempfile.mkdtemp(dir=_bup_tmp, prefix=prefix)
41 if wvfailure_count() == initial_failures:
42 subprocess.call(['chmod', '-R', 'u+rwX', tmpdir])
43 subprocess.call(['rm', '-rf', tmpdir])