<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import pytest <EOL> from hamcrest import assert_that , contains , all_of , has_entry , has_property , has_properties <EOL> from allure . constants import Severity , Status <EOL> from allure import utils <EOL> from . matchers import has_label <EOL> def severity_element ( value ) : <EOL> return has_properties ( attrib = all_of ( has_entry ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> has_entry ( '<STR_LIT:value>' , value ) ) ) <EOL> def has_test_with_severity ( test_name , severity_level ) : <EOL> return has_label ( test_name , label_value = severity_level , label_name = '<STR_LIT>' ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] , ids = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , utils . all_of ( Severity ) ) <EOL> def test_method_severity ( report_for , name , value , mark_way ) : <EOL> report = report_for ( """<STR_LIT>""" % ( mark_way % name ) ) <EOL> assert_that ( report , has_test_with_severity ( '<STR_LIT>' , value ) ) <EOL> def test_class_severity ( report_for ) : <EOL> """<STR_LIT>""" <EOL> report = report_for ( """<STR_LIT>""" ) <EOL> assert_that ( report , all_of ( <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . CRITICAL ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . TRIVIAL ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . CRITICAL ) <EOL> ) ) <EOL> def test_module_severity ( report_for ) : <EOL> """<STR_LIT>""" <EOL> report = report_for ( """<STR_LIT>""" ) <EOL> assert_that ( report , all_of ( <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . MINOR ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . MINOR ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . NORMAL ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . MINOR ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . CRITICAL ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . MINOR ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . CRITICAL ) , <EOL> has_test_with_severity ( '<STR_LIT>' , Severity . TRIVIAL ) <EOL> ) ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ [ Severity . CRITICAL ] , <EOL> [ Severity . CRITICAL , Severity . MINOR ] , <EOL> [ Severity . CRITICAL , Severity . MINOR , Severity . NORMAL ] , <EOL> [ Severity . NORMAL ] , <EOL> [ Severity . TRIVIAL ] , <EOL> [ Severity . BLOCKER ] , <EOL> ] ) <EOL> def test_run_only ( report_for , severities ) : <EOL> """<STR_LIT>""" <EOL> report = report_for ( """<STR_LIT>""" , extra_run_args = [ '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( severities ) ] ) <EOL> a_status , b_status , c_status = [ Status . PASSED if s in severities else Status . CANCELED for s in [ Severity . CRITICAL , Severity . MINOR , Severity . NORMAL ] ] <EOL> assert_that ( report . xpath ( "<STR_LIT>" ) , contains ( <EOL> all_of ( has_property ( '<STR_LIT:name>' , '<STR_LIT>' ) , has_property ( '<STR_LIT>' , has_entry ( '<STR_LIT:status>' , a_status ) ) ) , <EOL> all_of ( has_property ( '<STR_LIT:name>' , '<STR_LIT>' ) , has_property ( '<STR_LIT>' , has_entry ( '<STR_LIT:status>' , b_status ) ) ) , <EOL> all_of ( has_property ( '<STR_LIT:name>' , '<STR_LIT>' ) , has_property ( '<STR_LIT>' , has_entry ( '<STR_LIT:status>' , c_status ) ) ) <EOL> ) ) </s>
