From e3f171bc8c557de3815927af5bbf1d9fce2d7e25 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 6 Feb 2020 11:05:22 -0500 Subject: [PATCH 1/2] MNT: CI YAML formatting, extraneous .coveragerc --- .azure-pipelines/windows.yml | 2 +- .gitignore | 1 + .travis.yml | 2 +- for_testing/.coveragerc | 9 --------- 4 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 for_testing/.coveragerc diff --git a/.azure-pipelines/windows.yml b/.azure-pipelines/windows.yml index c7411a77c7..a73cb7b6de 100644 --- a/.azure-pipelines/windows.yml +++ b/.azure-pipelines/windows.yml @@ -100,7 +100,7 @@ jobs: -I test_rstutils ^ -I test_scaling ^ -I test_wrapstruct ^ - -I test_io + -I test_io displayName: 'Nose tests' condition: and(succeeded(), eq(variables['CHECK_TYPE'], 'nosetests')) - script: | diff --git a/.gitignore b/.gitignore index fd686f2781..e876975c27 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,4 @@ doc/source/reference venv/ .buildbot.patch .vscode +for_testing/ diff --git a/.travis.yml b/.travis.yml index 483efe29ec..f13b53f5a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -187,7 +187,7 @@ script: -I test_rstutils \ -I test_scaling \ -I test_wrapstruct \ - -I test_io + -I test_io elif [ "${CHECK_TYPE}" == "test" ]; then # Change into an innocuous directory and find tests from installation mkdir for_testing diff --git a/for_testing/.coveragerc b/for_testing/.coveragerc deleted file mode 100644 index 57747ec0d8..0000000000 --- a/for_testing/.coveragerc +++ /dev/null @@ -1,9 +0,0 @@ -[run] -branch = True -source = nibabel, nisext -include = */nibabel/*, */nisext/* -omit = - */externals/* - */benchmarks/* - */tests/* - nibabel/_version.py From eaab253772078df4e62145c970b54aa965c081b2 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 6 Feb 2020 11:06:16 -0500 Subject: [PATCH 2/2] TEST: Style and formatting --- nibabel/freesurfer/tests/test_io.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/nibabel/freesurfer/tests/test_io.py b/nibabel/freesurfer/tests/test_io.py index b457a6c00d..521923057f 100644 --- a/nibabel/freesurfer/tests/test_io.py +++ b/nibabel/freesurfer/tests/test_io.py @@ -92,16 +92,12 @@ def test_geometry(): warnings.filterwarnings('always', category=DeprecationWarning) read_geometry(surf_path, read_metadata=True) - assert( - any('volume information contained' in str(ww.message) - for ww in w)) - assert( - any('extension code' in str(ww.message) for ww in w)) + assert any('volume information contained' in str(ww.message) for ww in w) + assert any('extension code' in str(ww.message) for ww in w) volume_info['head'] = [1, 2] with clear_and_catch_warnings() as w: write_geometry(surf_path, coords, faces, create_stamp, volume_info) - assert( - any('Unknown extension' in str(ww.message) for ww in w)) + assert any('Unknown extension' in str(ww.message) for ww in w) volume_info['a'] = 0 with pytest.raises(ValueError): write_geometry(surf_path, coords, faces, create_stamp, volume_info) @@ -146,7 +142,7 @@ def test_morph_data(): new_path = 'test' write_morph_data(new_path, curv) curv2 = read_morph_data(new_path) - assert np.array_equal (curv2, curv) + assert np.array_equal(curv2, curv) def test_write_morph_data(): @@ -163,7 +159,7 @@ def test_write_morph_data(): with pytest.raises(ValueError): write_morph_data('test.curv', np.zeros(shape), big_num) - # Windows 32-bit overflows Python int + # Windows 32-bit overflows Python int if np.dtype(np.int) != np.dtype(np.int32): with pytest.raises(ValueError): write_morph_data('test.curv', strided_scalar((big_num,))) @@ -272,12 +268,10 @@ def test_write_annot_fill_ctab(): # values back. badannot = (10 * np.arange(nlabels, dtype=np.int32)).reshape(-1, 1) rgbal = np.hstack((rgba, badannot)) - print(labels) with clear_and_catch_warnings() as w: write_annot(annot_path, labels, rgbal, names, fill_ctab=False) - assert ( - any('Annotation values in {} will be incorrect'.format( - annot_path) == str(ww.message) for ww in w)) + assert any('Annotation values in {} will be incorrect'.format(annot_path) == str(ww.message) + for ww in w) labels2, rgbal2, names2 = read_annot(annot_path, orig_ids=True) names2 = [n.decode('ascii') for n in names2] assert np.all(np.isclose(rgbal2[:, :4], rgba)) @@ -291,9 +285,8 @@ def test_write_annot_fill_ctab(): rgbal[:, 2] * (2 ** 16)) with clear_and_catch_warnings() as w: write_annot(annot_path, labels, rgbal, names, fill_ctab=False) - assert( - not any('Annotation values in {} will be incorrect'.format( - annot_path) == str(ww.message) for ww in w)) + assert all('Annotation values in {} will be incorrect'.format(annot_path) != str(ww.message) + for ww in w) labels2, rgbal2, names2 = read_annot(annot_path) names2 = [n.decode('ascii') for n in names2] assert np.all(np.isclose(rgbal2[:, :4], rgba)) @@ -356,7 +349,7 @@ def test_label(): assert label.shape[0] <= 163842 labels, scalars = read_label(label_path, True) - assert (np.all(labels == label)) + assert np.all(labels == label) assert len(labels) == len(scalars)