From 09069b091bfef1a126531acc6462123f0844e0c0 Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Tue, 3 May 2022 15:51:02 +0200 Subject: [PATCH] Replace nose with pytest --- bob/io/base/test/test_image_support.py | 12 +++++------- bob/io/base/test/test_io.py | 6 +++--- bob/io/base/test_utils.py | 5 ++--- conda/meta.yaml | 5 +++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/bob/io/base/test/test_image_support.py b/bob/io/base/test/test_image_support.py index 04e1721..78f3cd2 100644 --- a/bob/io/base/test/test_image_support.py +++ b/bob/io/base/test/test_image_support.py @@ -10,10 +10,11 @@ import os -# import bob.io.image -import nose import numpy +# import bob.io.image +import pytest + from bob.io.base import load, write from ..test_utils import datafile, temporary_filename @@ -147,11 +148,8 @@ def test_image_load(): load(full_file).shape == (100, 100) # Testing exception - nose.tools.assert_raises( - RuntimeError, - lambda x: load(os.path.splitext(x)[0] + ".unknown"), - full_file, - ) + with pytest.raises(RuntimeError): + load(os.path.splitext(full_file)[0] + ".unknown") def test_image_exceptions(): diff --git a/bob/io/base/test/test_io.py b/bob/io/base/test/test_io.py index 22b8fca..de57e65 100644 --- a/bob/io/base/test/test_io.py +++ b/bob/io/base/test/test_io.py @@ -1,7 +1,7 @@ import os -import nose import numpy as np +import pytest from bob.io.base import load, save, vstack_features @@ -64,7 +64,7 @@ def test_io_vstack(): ]: np.all(vstack_features(reader, paths, True) == oracle(reader, paths)) - with nose.tools.assert_raises(AssertionError): + with pytest.raises(AssertionError): vstack_features(reader_wrong_size, paths) # test actual files @@ -89,7 +89,7 @@ def test_io_vstack(): np.all(vstack_features(load, paths) == reference) os.remove(paths[0]) # Check if RuntimeError is raised when one of the files is missing - with nose.tools.assert_raises(RuntimeError): + with pytest.raises(RuntimeError): vstack_features(load, paths) finally: try: diff --git a/bob/io/base/test_utils.py b/bob/io/base/test_utils.py index 6d8f3a0..6156c4b 100644 --- a/bob/io/base/test_utils.py +++ b/bob/io/base/test_utils.py @@ -10,8 +10,7 @@ import functools import os - -import nose.plugins.skip +import unittest def datafile(f, module=None, path="data"): @@ -110,7 +109,7 @@ def extension_available(extension): if extension in extensions(): return test(*args, **kwargs) else: - raise nose.plugins.skip.SkipTest( + raise unittest.SkipTest( 'Extension to handle "%s" files was not available at compile time' % extension ) diff --git a/conda/meta.yaml b/conda/meta.yaml index 2c121cf..7f9bf57 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -38,13 +38,14 @@ test: imports: - {{ name }} commands: - - nosetests --with-coverage --cover-package={{ name }} -sv {{ name }} + - pytest --verbose --cov {{ name }} --cov-report term-missing --cov-report html:{{ project_dir }}/sphinx/coverage --cov-report xml:{{ project_dir }}/coverage.xml --pyargs {{ name }} - sphinx-build -aEW {{ project_dir }}/doc {{ project_dir }}/sphinx - sphinx-build -aEb doctest {{ project_dir }}/doc sphinx - conda inspect linkages -p $PREFIX {{ name }} # [not win] - conda inspect objects -p $PREFIX {{ name }} # [osx] requires: - - nose {{ nose }} + - pytest {{ pytest }} + - pytest-cov {{ pytest_cov }} - coverage {{ coverage }} - sphinx {{ sphinx }} - sphinx_rtd_theme {{ sphinx_rtd_theme }} -- GitLab