Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Authors: Sylvain MARIE <sylvain.marie@se.com> 

2# + All contributors to <https://github.com/smarie/python-pytest-steps> 

3# 

4# License: 3-clause BSD, <https://github.com/smarie/python-pytest-steps/blob/master/LICENSE> 

5import pytest 

6from pytest_steps.steps import cross_steps_fixture 

7from pytest_steps.steps_generator import one_fixture_per_step 

8 

9try: 

10 from pytest_steps import pivot_steps_on_df, handle_steps_in_results_df 

11except ImportError: 

12 # this is normal if pytest-harvest is not installed 

13 pass 

14else: 

15 @pytest.fixture(scope='function') 

16 def session_results_df_steps_pivoted(request, session_results_df): 

17 """ 

18 A pivoted version of fixture `session_results_df` from pytest_harvest. 

19 In this version, there is one row per test with the results from all steps in columns. 

20 """ 

21 # Handle the steps 

22 session_results_df = handle_steps_in_results_df(session_results_df, keep_orig_id=False) 

23 

24 # Pivot 

25 return pivot_steps_on_df(session_results_df, pytest_session=request.session) 

26 

27 @pytest.fixture(scope='function') 

28 def module_results_df_steps_pivoted(request, module_results_df): 

29 """ 

30 A pivoted version of fixture `module_results_df` from pytest_harvest. 

31 In this version, there is one row per test with the results from all steps in columns. 

32 """ 

33 # Handle the steps 

34 module_results_df = handle_steps_in_results_df(module_results_df, keep_orig_id=False) 

35 

36 # Pivot 

37 return pivot_steps_on_df(module_results_df, pytest_session=request.session) 

38 

39 @pytest.fixture 

40 @one_fixture_per_step 

41 def step_bag(results_bag): 

42 """ 

43 Provides a separate pytest-harvest "results_bag" per step 

44 """ 

45 return results_bag 

46 

47 @pytest.fixture 

48 @cross_steps_fixture 

49 def cross_bag(results_bag): 

50 """ 

51 Provides a cross-step pytest-harvest "results_bag" for explicit mode 

52 """ 

53 return results_bag