@@ -120,3 +120,41 @@ def test_skip_attribute(mock_client_init):
120120 assert utils .attributes_to_tuples (actual_attributes ) == {
121121 (None , 'skip' )
122122 }
123+
124+
125+ @mock .patch (REPORT_PORTAL_SERVICE )
126+ def test_custom_runtime_attribute_report (mock_client_init ):
127+ """Verify custom attribute is reported.
128+
129+ :param mock_client_init: Pytest fixture
130+ """
131+ variables = {
132+ 'markers' : 'scope: to which test scope a test relates\n '
133+ 'runtime: runtime attribute mark'
134+ }
135+ variables .update (utils .DEFAULT_VARIABLES .items ())
136+ result = utils .run_pytest_tests (
137+ tests = ['examples/attributes/test_runtime_attribute.py' ],
138+ variables = variables
139+ )
140+ assert int (result ) == 0 , 'Exit code should be 0 (no errors)'
141+
142+ mock_client = mock_client_init .return_value
143+ assert mock_client .start_test_item .call_count > 0 , \
144+ '"start_test_item" called incorrect number of times'
145+ assert mock_client .finish_test_item .call_count > 0 , \
146+ '"finish_test_item" called incorrect number of times'
147+
148+ start_call_args = mock_client .start_test_item .call_args_list
149+ start_step_call_args = start_call_args [- 1 ][1 ]
150+ assert start_step_call_args ['attributes' ] == [
151+ {'key' : 'scope' , 'value' : 'smoke' }
152+ ]
153+
154+ finish_call_args = mock_client .finish_test_item .call_args_list
155+ finish_step_call_args = finish_call_args [- 1 ][1 ]
156+ actual_attributes = finish_step_call_args ['attributes' ]
157+ attribute_tuple_list = [(kv .get ('key' ), kv ['value' ])
158+ for kv in actual_attributes ]
159+
160+ assert set (attribute_tuple_list ) == {('scope' , 'smoke' ), (None , 'runtime' )}
0 commit comments