From 794dac2da6a1d4968965b8b390c38f4ed0b2c627 Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Thu, 19 Nov 2020 12:31:11 +0100 Subject: [PATCH] TST: Adjust test for new error destination --- datalad/customremotes/tests/test_archives.py | 4 +++- datalad/customremotes/tests/test_datalad.py | 3 ++- .../tests/test_add_archive_content.py | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/datalad/customremotes/tests/test_archives.py b/datalad/customremotes/tests/test_archives.py index 61edbe1acb..4ac846349a 100644 --- a/datalad/customremotes/tests/test_archives.py +++ b/datalad/customremotes/tests/test_archives.py @@ -35,6 +35,7 @@ assert_is_instance, assert_not_equal, assert_not_in, + assert_raises, assert_true, chpwd, eq_, @@ -53,6 +54,7 @@ StdOutErrCapture, WitlessRunner, ) +from datalad.support.exceptions import CommandError from ...utils import ( _path_, unlink, @@ -126,7 +128,7 @@ def test_basic_scenario(d, d2): assert_true(annex.file_has_content(fn_extracted)) annex.rm_url(fn_extracted, file_url) - assert_false(annex.drop(fn_extracted)['success']) + assert_raises(CommandError, annex.drop, fn_extracted) annex.add_url_to_file(fn_extracted, file_url) annex.drop(fn_extracted) diff --git a/datalad/customremotes/tests/test_datalad.py b/datalad/customremotes/tests/test_datalad.py index 46ae52f64d..21462e1fd2 100644 --- a/datalad/customremotes/tests/test_datalad.py +++ b/datalad/customremotes/tests/test_datalad.py @@ -62,10 +62,11 @@ def check_basic_scenario(url, d): with swallow_outputs() as cmo, swallow_logs() as cml: with assert_raises(CommandError) as cme: annex.add_urls([url + '_bogus']) + assert_in('addurl: 1 failed', cme.stderr) # assert_equal(cml.out, '') err, out = cmo.err, cmo.out assert_equal(out, '') - assert_in('addurl: 1 failed', err) + assert_equal(err, '') # and there should be nothing more diff --git a/datalad/interface/tests/test_add_archive_content.py b/datalad/interface/tests/test_add_archive_content.py index 1c164ddc4e..95eadd5fcd 100644 --- a/datalad/interface/tests/test_add_archive_content.py +++ b/datalad/interface/tests/test_add_archive_content.py @@ -50,7 +50,10 @@ ) from datalad.support.annexrepo import AnnexRepo -from datalad.support.exceptions import FileNotInRepositoryError +from datalad.support.exceptions import ( + CommandError, + FileNotInRepositoryError, +) from datalad.utils import ( chpwd, find_files, @@ -309,13 +312,13 @@ def d2_basic_checks(): # verify that we can't drop a file if archive key was dropped and online archive was removed or changed size! ;) repo.get(key_1tar, key=True) unlink(opj(path_orig, '1.tar.gz')) - res = repo.drop(key_1tar, key=True) - assert_equal(res['success'], False) - - assert_result_values_cond( - [res], 'note', - lambda x: '(Use --force to override this check, or adjust numcopies.)' in x - ) + with assert_raises(CommandError) as e: + repo.drop(key_1tar, key=True) + assert_equal(e.kwargs['stdout_json'][0]['success'], False) + assert_result_values_cond( + e.kwargs['stdout_json'], 'note', + lambda x: '(Use --force to override this check, or adjust numcopies.)' in x + ) assert exists(opj(repo.path, repo.get_contentlocation(key_1tar)))