]> arthur.barton.de Git - bup.git/commit
Check saved_errors before and after every test
authorRob Browning <rlb@defaultvalue.org>
Sun, 27 Mar 2016 00:33:57 +0000 (19:33 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 2 Apr 2016 16:12:48 +0000 (11:12 -0500)
commitbe2593062aa08b541343f80ebf05d0ca3a22c52a
tree367a841f62b4b0904d63faf447228115e1440d8e
parent2f15f993cf5fd40dd31f04006a6abd2367e5628d
Check saved_errors before and after every test

Add a new buptest module that includes a no_lingering_errors context
manager which provokes a wvtest failure if there are any saved_errors
before or after a test, and then clears them, and use that manager in
all of the Python tests so that unexpected errors will be detected
immediately, instead of causing an unrelated failure later, when testing
for expected saved_errors.

Add a temp_testdir context manager to replace all of the current
tmpdir-related boilerplate.

Rework all of the tests to use the two managers where appropriate, so
that this:

  def test_bloom():
      initial_failures = wvfailure_count()
      tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-tbloom-')
      ...
      if wvfailure_count() == initial_failures:
          subprocess.call(['rm', '-rf', tmpdir])

becomes this:

  def test_bloom():
      with no_lingering_errors(), test_tempdir('bup-tbloom-') as tmpdir:
          ...

While making the changes, clean up the imports to match the PEP 8 import
recommendations a bit more closely (excepting the suggestion to avoid
"import bar, baz", which seems odd given the blessing of "from foo
import bar, baz", where bar and baz could still be modules).

Thanks to Tadej Janež for reporting the initial issue.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
12 files changed:
buptest.py [new file with mode: 0644]
lib/bup/t/tbloom.py
lib/bup/t/tclient.py
lib/bup/t/tgit.py
lib/bup/t/thashsplit.py
lib/bup/t/thelpers.py
lib/bup/t/tindex.py
lib/bup/t/tmetadata.py
lib/bup/t/toptions.py
lib/bup/t/tshquote.py
lib/bup/t/tvint.py
lib/bup/t/txstat.py