|
2 | 2 | import allure |
3 | 3 | from hamcrest import assert_that, not_ |
4 | 4 | from allure_commons_test.report import has_test_case |
5 | | -from allure_commons_test.container import has_container |
6 | | -from allure_commons_test.container import has_before |
| 5 | +from allure_commons_test.container import has_container, has_before, has_after |
| 6 | +from allure_commons_test.result import has_step |
7 | 7 | from itertools import combinations_with_replacement |
8 | 8 |
|
9 | 9 | fixture_scopes = ["session", "module", "class", "function"] |
@@ -217,3 +217,58 @@ def test_with_titled_conftest_fixtures(first_fixture, second_fixture): |
217 | 217 | ) |
218 | 218 | ) |
219 | 219 | ) |
| 220 | + |
| 221 | + |
| 222 | +def test_fixture_override(allured_testdir): |
| 223 | + allured_testdir.testdir.makeconftest(""" |
| 224 | + import pytest |
| 225 | + import allure |
| 226 | +
|
| 227 | + @pytest.fixture |
| 228 | + def my_fixture(): |
| 229 | + with allure.step('Step in before in original fixture'): |
| 230 | + pass |
| 231 | + yield |
| 232 | + with allure.step('Step in after in original fixture'): |
| 233 | + pass |
| 234 | +
|
| 235 | + """) |
| 236 | + |
| 237 | + allured_testdir.testdir.makepyfile(""" |
| 238 | + import pytest |
| 239 | + import allure |
| 240 | +
|
| 241 | + @pytest.fixture |
| 242 | + def my_fixture(my_fixture): |
| 243 | + with allure.step('Step in before in redefined fixture'): |
| 244 | + pass |
| 245 | + yield |
| 246 | + with allure.step('Step in after in redefined fixture'): |
| 247 | + pass |
| 248 | +
|
| 249 | + def test_with_redefined_fixture(my_fixture): |
| 250 | + pass |
| 251 | + """) |
| 252 | + |
| 253 | + allured_testdir.run_with_allure() |
| 254 | + |
| 255 | + assert_that(allured_testdir.allure_report, |
| 256 | + has_test_case("test_with_redefined_fixture", |
| 257 | + has_container(allured_testdir.allure_report, |
| 258 | + has_before("my_fixture", |
| 259 | + has_step("Step in before in original fixture") |
| 260 | + ), |
| 261 | + has_after("my_fixture::0", |
| 262 | + has_step("Step in after in original fixture") |
| 263 | + ) |
| 264 | + ), |
| 265 | + has_container(allured_testdir.allure_report, |
| 266 | + has_before("my_fixture", |
| 267 | + has_step("Step in before in redefined fixture") |
| 268 | + ), |
| 269 | + has_after("my_fixture::0", |
| 270 | + has_step("Step in after in redefined fixture") |
| 271 | + ) |
| 272 | + ), |
| 273 | + ) |
| 274 | + ) |
0 commit comments