@@ -103,6 +103,7 @@ mod tests {
103103 #[ test_case( Rule :: SuspiciousURLOpenUsage , Path :: new( "S310.py" ) ) ]
104104 #[ test_case( Rule :: SuspiciousNonCryptographicRandomUsage , Path :: new( "S311.py" ) ) ]
105105 #[ test_case( Rule :: SuspiciousTelnetUsage , Path :: new( "S312.py" ) ) ]
106+ #[ test_case( Rule :: UnsafeMarkupUse , Path :: new( "S704.py" ) ) ]
106107 fn preview_rules ( rule_code : Rule , path : & Path ) -> Result < ( ) > {
107108 let snapshot = format ! (
108109 "preview__{}_{}" ,
@@ -120,6 +121,51 @@ mod tests {
120121 Ok ( ( ) )
121122 }
122123
124+ #[ test_case( Rule :: UnsafeMarkupUse , Path :: new( "S704_extend_markup_names.py" ) ) ]
125+ #[ test_case( Rule :: UnsafeMarkupUse , Path :: new( "S704_skip_early_out.py" ) ) ]
126+ fn extend_allowed_callable ( rule_code : Rule , path : & Path ) -> Result < ( ) > {
127+ let snapshot = format ! (
128+ "extend_allow_callables__{}_{}" ,
129+ rule_code. noqa_code( ) ,
130+ path. to_string_lossy( )
131+ ) ;
132+ let diagnostics = test_path (
133+ Path :: new ( "flake8_bandit" ) . join ( path) . as_path ( ) ,
134+ & LinterSettings {
135+ flake8_bandit : super :: settings:: Settings {
136+ extend_markup_names : vec ! [ "webhelpers.html.literal" . to_string( ) ] ,
137+ ..Default :: default ( )
138+ } ,
139+ preview : PreviewMode :: Enabled ,
140+ ..LinterSettings :: for_rule ( rule_code)
141+ } ,
142+ ) ?;
143+ assert_messages ! ( snapshot, diagnostics) ;
144+ Ok ( ( ) )
145+ }
146+
147+ #[ test_case( Rule :: UnsafeMarkupUse , Path :: new( "S704_whitelisted_markup_calls.py" ) ) ]
148+ fn whitelisted_markup_calls ( rule_code : Rule , path : & Path ) -> Result < ( ) > {
149+ let snapshot = format ! (
150+ "whitelisted_markup_calls__{}_{}" ,
151+ rule_code. noqa_code( ) ,
152+ path. to_string_lossy( )
153+ ) ;
154+ let diagnostics = test_path (
155+ Path :: new ( "flake8_bandit" ) . join ( path) . as_path ( ) ,
156+ & LinterSettings {
157+ flake8_bandit : super :: settings:: Settings {
158+ allowed_markup_calls : vec ! [ "bleach.clean" . to_string( ) ] ,
159+ ..Default :: default ( )
160+ } ,
161+ preview : PreviewMode :: Enabled ,
162+ ..LinterSettings :: for_rule ( rule_code)
163+ } ,
164+ ) ?;
165+ assert_messages ! ( snapshot, diagnostics) ;
166+ Ok ( ( ) )
167+ }
168+
123169 #[ test]
124170 fn check_hardcoded_tmp_additional_dirs ( ) -> Result < ( ) > {
125171 let diagnostics = test_path (
@@ -132,7 +178,7 @@ mod tests {
132178 "/dev/shm" . to_string( ) ,
133179 "/foo" . to_string( ) ,
134180 ] ,
135- check_typed_exception : false ,
181+ .. Default :: default ( )
136182 } ,
137183 ..LinterSettings :: for_rule ( Rule :: HardcodedTempFile )
138184 } ,
0 commit comments