diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-05-10 19:09:17 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-05-10 19:09:25 +0900 |
commit | e6ad12b4e15dd11232d591b9faedcc9ca2b50af6 (patch) | |
tree | d824d222f328f80071a3c11f245aa3d8a2bbcf91 | |
parent | ef8bb17f2572792b6ae8e797417bdfa57f7af41e (diff) | |
download | psych-e6ad12b4e15dd11232d591b9faedcc9ca2b50af6.zip |
Use assert_raise instead of assert_raises
-rw-r--r-- | test/psych/test_class.rb | 4 | ||||
-rw-r--r-- | test/psych/test_document.rb | 2 | ||||
-rw-r--r-- | test/psych/test_emitter.rb | 10 | ||||
-rw-r--r-- | test/psych/test_encoding.rb | 4 | ||||
-rw-r--r-- | test/psych/test_exception.rb | 30 | ||||
-rw-r--r-- | test/psych/test_merge_keys.rb | 2 | ||||
-rw-r--r-- | test/psych/test_parser.rb | 16 | ||||
-rw-r--r-- | test/psych/test_psych.rb | 14 | ||||
-rw-r--r-- | test/psych/test_safe_load.rb | 28 | ||||
-rw-r--r-- | test/psych/test_yaml.rb | 6 | ||||
-rw-r--r-- | test/psych/test_yamlstore.rb | 2 | ||||
-rw-r--r-- | test/psych/visitors/test_yaml_tree.rb | 4 |
12 files changed, 61 insertions, 61 deletions
diff --git a/test/psych/test_class.rb b/test/psych/test_class.rb index 71f7ec3..faa504c 100644 --- a/test/psych/test_class.rb +++ b/test/psych/test_class.rb @@ -7,13 +7,13 @@ module Psych end def test_cycle_anonymous_class - assert_raises(::TypeError) do + assert_raise(::TypeError) do assert_cycle(Class.new) end end def test_cycle_anonymous_module - assert_raises(::TypeError) do + assert_raise(::TypeError) do assert_cycle(Module.new) end end diff --git a/test/psych/test_document.rb b/test/psych/test_document.rb index a88dd32..cf3b700 100644 --- a/test/psych/test_document.rb +++ b/test/psych/test_document.rb @@ -30,7 +30,7 @@ module Psych end def test_emit_bad_tag - assert_raises(RuntimeError) do + assert_raise(RuntimeError) do @doc.tag_directives = [['!']] @stream.yaml end diff --git a/test/psych/test_emitter.rb b/test/psych/test_emitter.rb index 52d5e9d..506d722 100644 --- a/test/psych/test_emitter.rb +++ b/test/psych/test_emitter.rb @@ -40,7 +40,7 @@ module Psych end def test_start_stream_arg_error - assert_raises(TypeError) do + assert_raise(TypeError) do @emitter.start_stream 'asdfasdf' end end @@ -56,7 +56,7 @@ module Psych [[], [nil,nil], false], [[1,1], [[nil, "tag:TALOS"]], 0], ].each do |args| - assert_raises(TypeError) do + assert_raise(TypeError) do @emitter.start_document(*args) end end @@ -73,7 +73,7 @@ module Psych ['foo', nil, nil, false, true, :foo], [nil, nil, nil, false, true, 1], ].each do |args| - assert_raises(TypeError) do + assert_raise(TypeError) do @emitter.scalar(*args) end end @@ -83,11 +83,11 @@ module Psych @emitter.start_stream Psych::Nodes::Stream::UTF8 @emitter.start_document [], [], false - assert_raises(TypeError) do + assert_raise(TypeError) do @emitter.start_sequence(nil, Object.new, true, 1) end - assert_raises(TypeError) do + assert_raise(TypeError) do @emitter.start_sequence(nil, nil, true, :foo) end end diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb index ef66531..e5831c9 100644 --- a/test/psych/test_encoding.rb +++ b/test/psych/test_encoding.rb @@ -63,7 +63,7 @@ module Psych # If the external encoding isn't utf8, utf16le, or utf16be, we cannot # process the file. File.open(t.path, 'r', :encoding => 'SHIFT_JIS') do |f| - assert_raises Psych::SyntaxError do + assert_raise Psych::SyntaxError do Psych.load(f) end end @@ -121,7 +121,7 @@ module Psych def test_emit_alias @emitter.start_stream Psych::Parser::UTF8 @emitter.start_document [], [], true - e = assert_raises(RuntimeError) do + e = assert_raise(RuntimeError) do @emitter.alias 'ドラえもん'.encode('EUC-JP') end assert_match(/alias value/, e.message) diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb index 78601d0..4d76081 100644 --- a/test/psych/test_exception.rb +++ b/test/psych/test_exception.rb @@ -44,31 +44,31 @@ module Psych end def test_load_takes_file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load '--- `' end assert_nil ex.file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load '--- `', filename: 'meow' end assert_equal 'meow', ex.file # deprecated interface - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load '--- `', 'deprecated' end assert_equal 'deprecated', ex.file end def test_psych_parse_stream_takes_file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse_stream '--- `' end assert_nil ex.file assert_match '(<unknown>)', ex.message - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse_stream '--- `', filename: 'omg!' end assert_equal 'omg!', ex.file @@ -76,19 +76,19 @@ module Psych end def test_load_stream_takes_file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load_stream '--- `' end assert_nil ex.file assert_match '(<unknown>)', ex.message - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load_stream '--- `', filename: 'omg!' end assert_equal 'omg!', ex.file # deprecated interface - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load_stream '--- `', 'deprecated' end assert_equal 'deprecated', ex.file @@ -99,7 +99,7 @@ module Psych t.binmode t.write '--- `' t.close - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse_file t.path end assert_equal t.path, ex.file @@ -111,7 +111,7 @@ module Psych t.binmode t.write '--- `' t.close - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.load_file t.path end assert_equal t.path, ex.file @@ -123,7 +123,7 @@ module Psych t.binmode t.write '--- `' t.close - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.safe_load_file t.path end assert_equal t.path, ex.file @@ -131,26 +131,26 @@ module Psych end def test_psych_parse_takes_file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse '--- `' end assert_match '(<unknown>)', ex.message assert_nil ex.file - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse '--- `', filename: 'omg!' end assert_match 'omg!', ex.message # deprecated interface - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do Psych.parse '--- `', 'deprecated' end assert_match 'deprecated', ex.message end def test_attributes - e = assert_raises(Psych::SyntaxError) { + e = assert_raise(Psych::SyntaxError) { Psych.load '--- `foo' } diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb index 08ffe58..24f2d62 100644 --- a/test/psych/test_merge_keys.rb +++ b/test/psych/test_merge_keys.rb @@ -117,7 +117,7 @@ development: bar: << : *foo eoyml - exp = assert_raises(Psych::BadAlias) { Psych.load yaml } + exp = assert_raise(Psych::BadAlias) { Psych.load yaml } assert_match 'foo', exp.message end diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index e8225da..3604e7c 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -63,7 +63,7 @@ module Psych parser = Psych::Parser.new klass.new 2.times { - assert_raises(RuntimeError, method.to_s) do + assert_raise(RuntimeError, method.to_s) do parser.parse yaml end } @@ -77,7 +77,7 @@ module Psych end def test_filename - ex = assert_raises(Psych::SyntaxError) do + ex = assert_raise(Psych::SyntaxError) do @parser.parse '--- `', 'omg!' end assert_match 'omg!', ex.message @@ -180,7 +180,7 @@ module Psych def o.external_encoding; nil end def o.read len; self end - assert_raises(TypeError) do + assert_raise(TypeError) do @parser.parse o end end @@ -193,23 +193,23 @@ module Psych end def test_syntax_error - assert_raises(Psych::SyntaxError) do + assert_raise(Psych::SyntaxError) do @parser.parse("---\n\"foo\"\n\"bar\"\n") end end def test_syntax_error_twice - assert_raises(Psych::SyntaxError) do + assert_raise(Psych::SyntaxError) do @parser.parse("---\n\"foo\"\n\"bar\"\n") end - assert_raises(Psych::SyntaxError) do + assert_raise(Psych::SyntaxError) do @parser.parse("---\n\"foo\"\n\"bar\"\n") end end def test_syntax_error_has_path_for_string - e = assert_raises(Psych::SyntaxError) do + e = assert_raise(Psych::SyntaxError) do @parser.parse("---\n\"foo\"\n\"bar\"\n") end assert_match '(<unknown>):', e.message @@ -219,7 +219,7 @@ module Psych io = StringIO.new "---\n\"foo\"\n\"bar\"\n" def io.path; "hello!"; end - e = assert_raises(Psych::SyntaxError) do + e = assert_raise(Psych::SyntaxError) do @parser.parse(io) end assert_match "(#{io.path}):", e.message diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 1bfa523..76a3627 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -16,7 +16,7 @@ class TestPsych < Psych::TestCase end def test_line_width_invalid - assert_raises(ArgumentError) { Psych.dump('x', { :line_width => -2 }) } + assert_raise(ArgumentError) { Psych.dump('x', { :line_width => -2 }) } end def test_line_width_no_limit @@ -61,7 +61,7 @@ class TestPsych < Psych::TestCase end def test_load_argument_error - assert_raises(TypeError) do + assert_raise(TypeError) do Psych.load nil end end @@ -75,7 +75,7 @@ class TestPsych < Psych::TestCase end def test_parse_raises_on_bad_input - assert_raises(Psych::SyntaxError) { Psych.parse("--- `") } + assert_raise(Psych::SyntaxError) { Psych.parse("--- `") } end def test_parse_with_fallback @@ -83,7 +83,7 @@ class TestPsych < Psych::TestCase end def test_non_existing_class_on_deserialize - e = assert_raises(ArgumentError) do + e = assert_raise(ArgumentError) do Psych.load("--- !ruby/object:NonExistent\nfoo: 1") end assert_equal 'undefined class/module NonExistent', e.message @@ -143,7 +143,7 @@ class TestPsych < Psych::TestCase end def test_load_stream_raises_on_bad_input - assert_raises(Psych::SyntaxError) { Psych.load_stream("--- `") } + assert_raise(Psych::SyntaxError) { Psych.load_stream("--- `") } end def test_parse_stream @@ -175,7 +175,7 @@ class TestPsych < Psych::TestCase end def test_parse_stream_raises_on_bad_input - assert_raises(Psych::SyntaxError) { Psych.parse_stream("--- `") } + assert_raise(Psych::SyntaxError) { Psych.parse_stream("--- `") } end def test_add_builtin_type @@ -325,7 +325,7 @@ class TestPsych < Psych::TestCase t.write("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") t.close assert_equal 0..42, Psych.safe_load_file(t.path, permitted_classes: [Range]) - assert_raises(Psych::DisallowedClass) { + assert_raise(Psych::DisallowedClass) { Psych.safe_load_file(t.path) } } diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb index e397271..d13ce7c 100644 --- a/test/psych/test_safe_load.rb +++ b/test/psych/test_safe_load.rb @@ -22,7 +22,7 @@ module Psych def test_no_recursion x = [] x << x - assert_raises(Psych::BadAlias) do + assert_raise(Psych::BadAlias) do Psych.safe_load Psych.dump(x) end end @@ -37,7 +37,7 @@ module Psych def test_permitted_symbol yml = Psych.dump :foo - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load yml end assert_equal( @@ -54,15 +54,15 @@ module Psych end def test_symbol - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do assert_safe_cycle :foo end - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load '--- !ruby/symbol foo', permitted_classes: [] end # deprecated interface - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load '--- !ruby/symbol foo', [] end @@ -75,16 +75,16 @@ module Psych end def test_foo - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load '--- !ruby/object:Foo {}', permitted_classes: [Foo] end # deprecated interface - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load '--- !ruby/object:Foo {}', [Foo] end - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do assert_safe_cycle Foo.new end assert_kind_of(Foo, Psych.safe_load(Psych.dump(Foo.new), permitted_classes: [Foo])) @@ -96,7 +96,7 @@ module Psych X = Struct.new(:x) def test_struct_depends_on_sym assert_safe_cycle(X.new, permitted_classes: [X, Symbol]) - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do cycle X.new, permitted_classes: [X] end end @@ -107,14 +107,14 @@ module Psych foo: bar eoyml - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load(<<-eoyml, permitted_classes: [Struct]) --- !ruby/struct foo: bar eoyml end - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load(<<-eoyml, permitted_classes: [Symbol]) --- !ruby/struct foo: bar @@ -128,14 +128,14 @@ module Psych foo: bar eoyml - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load(<<-eoyml, [Struct]) --- !ruby/struct foo: bar eoyml end - assert_raises(Psych::DisallowedClass) do + assert_raise(Psych::DisallowedClass) do Psych.safe_load(<<-eoyml, [Symbol]) --- !ruby/struct foo: bar @@ -152,7 +152,7 @@ module Psych end def test_safe_load_raises_on_bad_input - assert_raises(Psych::SyntaxError) { Psych.safe_load("--- `") } + assert_raise(Psych::SyntaxError) { Psych.safe_load("--- `") } end private diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb index 84cbe26..b16a00f 100644 --- a/test/psych/test_yaml.rb +++ b/test/psych/test_yaml.rb @@ -17,7 +17,7 @@ class Psych_Unit_Tests < Psych::TestCase end def test_y_method - assert_raises(NoMethodError) do + assert_raise(NoMethodError) do OpenStruct.new.y 1 end end @@ -1077,7 +1077,7 @@ EOY # Read Psych dumped by the ruby 1.8.3. assert_to_yaml( Rational(1, 2), "!ruby/object:Rational 1/2\n" ) - assert_raises( ArgumentError ) { Psych.load("!ruby/object:Rational INVALID/RATIONAL\n") } + assert_raise( ArgumentError ) { Psych.load("!ruby/object:Rational INVALID/RATIONAL\n") } end def test_ruby_complex @@ -1089,7 +1089,7 @@ EOY # Read Psych dumped by the ruby 1.8.3. assert_to_yaml( Complex(3, 4), "!ruby/object:Complex 3+4i\n" ) - assert_raises( ArgumentError ) { Psych.load("!ruby/object:Complex INVALID+COMPLEXi\n") } + assert_raise( ArgumentError ) { Psych.load("!ruby/object:Complex INVALID+COMPLEXi\n") } end def test_emitting_indicators diff --git a/test/psych/test_yamlstore.rb b/test/psych/test_yamlstore.rb index d1e927c..1cd3ec4 100644 --- a/test/psych/test_yamlstore.rb +++ b/test/psych/test_yamlstore.rb @@ -76,7 +76,7 @@ module Psych end def test_writing_inside_readonly_transaction_raises_error - assert_raises(PStore::Error) do + assert_raise(PStore::Error) do @yamlstore.transaction(true) do @yamlstore[:foo] = "bar" end diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 69885ee..2e68308 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -127,11 +127,11 @@ module Psych end def test_anon_class - assert_raises(TypeError) do + assert_raise(TypeError) do @v.accept Class.new end - assert_raises(TypeError) do + assert_raise(TypeError) do Psych.dump(Class.new) end end |