diff --git a/examples/fixtures/test_failure_fixture_teardown/conftest.py b/examples/fixtures/test_failure_fixture_teardown/conftest.py new file mode 100644 index 0000000..5ac5d93 --- /dev/null +++ b/examples/fixtures/test_failure_fixture_teardown/conftest.py @@ -0,0 +1,33 @@ +# Copyright 2024 EPAM Systems +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +from unittest import mock + +import pytest +from reportportal_client import RPLogger + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) +logging.setLoggerClass(RPLogger) + +LOG_MESSAGE_BEFORE_YIELD = 'Log message before yield' +LOG_MESSAGE_TEARDOWN = 'Log message for teardown' + + +@pytest.fixture +def fixture_teardown_config(): + logging.error(LOG_MESSAGE_BEFORE_YIELD) + yield mock.Mock() + logging.error(LOG_MESSAGE_TEARDOWN) diff --git a/examples/fixtures/test_failure_fixture_teardown/test_fixture_teardown.py b/examples/fixtures/test_failure_fixture_teardown/test_fixture_teardown.py new file mode 100644 index 0000000..931fa45 --- /dev/null +++ b/examples/fixtures/test_failure_fixture_teardown/test_fixture_teardown.py @@ -0,0 +1,32 @@ +# Copyright 2024 EPAM Systems +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from time import sleep + + +def test_failure_fixture_teardown(fixture_teardown_config): + sleep(0.001) + assert fixture_teardown_config is not None