diff --git a/examples/fixtures/class_fixture_return/test_fixture_session_setup.py b/examples/fixtures/class_fixture_return/test_fixture_session_setup.py index 79f2c7e..a2eecb7 100644 --- a/examples/fixtures/class_fixture_return/test_fixture_session_setup.py +++ b/examples/fixtures/class_fixture_return/test_fixture_session_setup.py @@ -24,6 +24,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -class TestClass: - def test_fixture_class_setup(self, mocked_config): +class TestClassOne: + def test_fixture_class_setup_first(self, mocked_config): + assert mocked_config is not None + + def test_fixture_class_setup_second(self, mocked_config): + assert mocked_config is not None + + +class TestClassTwo: + def test_fixture_class_setup_forth(self, mocked_config): + assert mocked_config is not None + + def test_fixture_class_setup_fifth(self, mocked_config): assert mocked_config is not None diff --git a/examples/fixtures/package_fixture_return/test_fixture_package_setup_first.py b/examples/fixtures/package_fixture_return/test_fixture_package_setup_first.py new file mode 100644 index 0000000..955dad3 --- /dev/null +++ b/examples/fixtures/package_fixture_return/test_fixture_package_setup_first.py @@ -0,0 +1,28 @@ +# 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. + +def test_fixture_package_setup_first(mocked_config): + assert mocked_config is not None diff --git a/examples/fixtures/package_fixture_return/test_fixture_package_setup.py b/examples/fixtures/package_fixture_return/test_fixture_package_setup_second.py similarity index 93% rename from examples/fixtures/package_fixture_return/test_fixture_package_setup.py rename to examples/fixtures/package_fixture_return/test_fixture_package_setup_second.py index 7d5601e..138f4b9 100644 --- a/examples/fixtures/package_fixture_return/test_fixture_package_setup.py +++ b/examples/fixtures/package_fixture_return/test_fixture_package_setup_second.py @@ -24,9 +24,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -def test_fixture_package_setup_first(mocked_config): - assert mocked_config is not None - - def test_fixture_package_setup_second(mocked_config): assert mocked_config is not None diff --git a/examples/fixtures/session_fixture_return/test_fixture_session_setup_first.py b/examples/fixtures/session_fixture_return/test_fixture_session_setup_first.py new file mode 100644 index 0000000..83d4f1e --- /dev/null +++ b/examples/fixtures/session_fixture_return/test_fixture_session_setup_first.py @@ -0,0 +1,29 @@ +# 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. + + +def test_fixture_session_setup_first(mocked_config): + assert mocked_config is not None diff --git a/examples/fixtures/session_fixture_return/test_fixture_session_setup.py b/examples/fixtures/session_fixture_return/test_fixture_session_setup_second.py similarity index 93% rename from examples/fixtures/session_fixture_return/test_fixture_session_setup.py rename to examples/fixtures/session_fixture_return/test_fixture_session_setup_second.py index d56dec0..2bd544d 100644 --- a/examples/fixtures/session_fixture_return/test_fixture_session_setup.py +++ b/examples/fixtures/session_fixture_return/test_fixture_session_setup_second.py @@ -25,9 +25,5 @@ # limitations under the License. -def test_fixture_session_setup_first(mocked_config): - assert mocked_config is not None - - def test_fixture_session_setup_second(mocked_config): assert mocked_config is not None diff --git a/examples/fixtures/test_fixture_yield/conftest.py b/examples/fixtures/test_fixture_return_none/conftest.py similarity index 71% rename from examples/fixtures/test_fixture_yield/conftest.py rename to examples/fixtures/test_fixture_return_none/conftest.py index 0f5fa12..8496549 100644 --- a/examples/fixtures/test_fixture_yield/conftest.py +++ b/examples/fixtures/test_fixture_return_none/conftest.py @@ -12,12 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from unittest import mock +import logging import pytest +from reportportal_client import RPLogger + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) +logging.setLoggerClass(RPLogger) + +LOG_MESSAGE_SETUP = 'Log message for setup and return None' @pytest.fixture def mocked_config(): - yield mock.Mock() - print('teardown') + LOGGER.warn(LOG_MESSAGE_SETUP) diff --git a/examples/fixtures/test_fixture_return/test_fixture_setup.py b/examples/fixtures/test_fixture_return_none/test_fixture_return_none.py similarity index 100% rename from examples/fixtures/test_fixture_return/test_fixture_setup.py rename to examples/fixtures/test_fixture_return_none/test_fixture_return_none.py diff --git a/examples/fixtures/test_fixture_return/conftest.py b/examples/fixtures/test_fixture_setup/conftest.py similarity index 74% rename from examples/fixtures/test_fixture_return/conftest.py rename to examples/fixtures/test_fixture_setup/conftest.py index 56d66de..eeecc1b 100644 --- a/examples/fixtures/test_fixture_return/conftest.py +++ b/examples/fixtures/test_fixture_setup/conftest.py @@ -12,12 +12,20 @@ # 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_SETUP = 'Log message for setup' @pytest.fixture def mocked_config(): - print('setup') + logging.error(LOG_MESSAGE_SETUP) return mock.Mock() diff --git a/examples/fixtures/test_fixture_setup/test_fixture_setup.py b/examples/fixtures/test_fixture_setup/test_fixture_setup.py new file mode 100644 index 0000000..0427072 --- /dev/null +++ b/examples/fixtures/test_fixture_setup/test_fixture_setup.py @@ -0,0 +1,29 @@ +# 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. + + +def test_fixture_setup(mocked_config): + assert mocked_config is not None diff --git a/examples/fixtures/test_fixture_teardown/conftest.py b/examples/fixtures/test_fixture_teardown/conftest.py new file mode 100644 index 0000000..7e53f49 --- /dev/null +++ b/examples/fixtures/test_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 mocked_config(): + logging.error(LOG_MESSAGE_BEFORE_YIELD) + yield mock.Mock() + logging.error(LOG_MESSAGE_TEARDOWN) diff --git a/examples/fixtures/test_fixture_yield/test_fixture_teardown.py b/examples/fixtures/test_fixture_teardown/test_fixture_teardown.py similarity index 96% rename from examples/fixtures/test_fixture_yield/test_fixture_teardown.py rename to examples/fixtures/test_fixture_teardown/test_fixture_teardown.py index 46472f8..52be323 100644 --- a/examples/fixtures/test_fixture_yield/test_fixture_teardown.py +++ b/examples/fixtures/test_fixture_teardown/test_fixture_teardown.py @@ -24,6 +24,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from time import sleep + def test_fixture_teardown(mocked_config): + sleep(0.001) assert mocked_config is not None