Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 18, 2024
1 parent be62554 commit fcd2667
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/fixtures/test_failure_fixture_teardown/conftest.py
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fcd2667

Please sign in to comment.