diff --git a/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc b/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc index 057e2026828..610cd63a606 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/consumers/tree_consumer.cc @@ -58,8 +58,10 @@ Status TreeConsumer::Init(std::shared_ptr d) { } Status TreeConsumer::Terminate() { - CHECK_FAIL_RETURN_UNEXPECTED(tree_adapter_->AllTasks() != nullptr, " Execution tree has not been built"); - return tree_adapter_->AllTasks()->ServiceStop(); + if (tree_adapter_->AllTasks() != nullptr) { + return tree_adapter_->AllTasks()->ServiceStop(); + } + return Status::OK(); } #ifndef ENABLE_SECURITY diff --git a/tests/ut/python/dataset/conftest.py b/tests/ut/python/dataset/conftest.py index 8a05c106d63..d59f0bae50f 100644 --- a/tests/ut/python/dataset/conftest.py +++ b/tests/ut/python/dataset/conftest.py @@ -14,15 +14,16 @@ # ============================================================================ """ @File : conftest.py -@Desc : common fixtures for pytest +@Desc : common fixtures for pytest dataset """ import pytest from mindspore.dataset.engine.iterators import _cleanup, _unset_iterator_cleanup -@pytest.fixture(autouse=True) +@pytest.fixture(scope="function", autouse=True) def close_iterators(): yield + # Note: code after `yield` is teardown code _cleanup() _unset_iterator_cleanup() diff --git a/tests/ut/python/dataset/test_reset.py b/tests/ut/python/dataset/test_reset.py index 17951eb19f0..7bc4323e7d9 100644 --- a/tests/ut/python/dataset/test_reset.py +++ b/tests/ut/python/dataset/test_reset.py @@ -209,7 +209,7 @@ def test_reset_mindrecord(add_and_remove_cv_file): # pylint: disable=unused-arg run_reset(data, num_epochs=num_epochs, failure_point=failure_point, reset_step=reset_step) -def skip_test_reset_np_error(): +def test_reset_np_error(): """ Feature: dataset recovery Description: Simple test of data pipeline reset feature for error cases (step is negative, or larger than expected)