Use assert_raise and skip for test/unit

This commit is contained in:
aycabta 2019-08-16 06:45:36 +09:00
Родитель f71bd7477e
Коммит a458317b91
14 изменённых файлов: 48 добавлений и 48 удалений

Просмотреть файл

@ -294,7 +294,7 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
c = RDoc::Comment.new nil, @top_level
c.document = @RM::Document.new
e = assert_raises RDoc::Error do
e = assert_raise RDoc::Error do
c.text = 'other'
end

Просмотреть файл

@ -171,7 +171,7 @@ class TestRDocEncoding < RDoc::TestCase
assert_nil encoding
assert_raises ArgumentError do
assert_raise ArgumentError do
s = RDoc::Encoding.detect_encoding "# -*- encoding: undecided -*-\n"
end
end

Просмотреть файл

@ -168,7 +168,7 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
begin
require 'zlib'
rescue LoadError
omit "no zlib"
skip "no zlib"
end
@g.generate
@g.generate_gzipped

Просмотреть файл

@ -32,7 +32,7 @@ class TestRDocI18nLocale < RDoc::TestCase
begin
require 'gettext/po_parser'
rescue LoadError
omit 'gettext gem is not found'
skip 'gettext gem is not found'
end
fr_locale_dir = File.join @locale_dir, 'fr'

Просмотреть файл

@ -717,7 +717,7 @@ Some text. ^[With a footnote]
def test_parse_note_no_notes
@parser.notes = false
assert_raises RDoc::Markdown::ParseError do
assert_raise RDoc::Markdown::ParseError do
parse "Some text.[^1]"
end
end

Просмотреть файл

@ -75,7 +75,7 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def test_add_word_pair_angle
e = assert_raises ArgumentError do
e = assert_raise ArgumentError do
@am.add_word_pair '<', '>', 'angles'
end
@ -83,7 +83,7 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
def test_add_word_pair_invalid
assert_raises ArgumentError do
assert_raise ArgumentError do
@am.add_word_pair("<", "<", :TEST)
end
end

Просмотреть файл

@ -34,7 +34,7 @@ class TestRDocMarkupDocument < RDoc::TestCase
assert_empty @d
assert_raises ArgumentError do
assert_raise ArgumentError do
@d << 'hi'
end
end

Просмотреть файл

@ -1087,7 +1087,7 @@ the time
assert_equal [:NEWLINE, "\n", 9, 0], parser.peek_token
assert_raises RDoc::Markup::Parser::ParseError do
assert_raise RDoc::Markup::Parser::ParseError do
parser.skip :NONE
end
@ -1661,7 +1661,7 @@ Example heading:
assert_equal [:HEADER, 1, 0, 0], parser.peek_token
assert_raises @RMP::Error do
assert_raise @RMP::Error do
parser.unget
end

Просмотреть файл

@ -17,8 +17,8 @@ class TestRDocOptions < RDoc::TestCase
end
def test_check_files
omit "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
omit "assumes that euid is not root" if Process.euid == 0
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
skip "assumes that euid is not root" if Process.euid == 0
out, err = capture_output do
temp_dir do
@ -288,7 +288,7 @@ rdoc_include:
end
def test_parse_formatter
e = assert_raises OptionParser::InvalidOption do
e = assert_raise OptionParser::InvalidOption do
@options.parse %w[--format darkfish --format ri]
end
@ -297,7 +297,7 @@ rdoc_include:
end
def test_parse_formatter_ri
e = assert_raises OptionParser::InvalidOption do
e = assert_raise OptionParser::InvalidOption do
@options.parse %w[--format darkfish --ri]
end
@ -306,7 +306,7 @@ rdoc_include:
@options = RDoc::Options.new
e = assert_raises OptionParser::InvalidOption do
e = assert_raise OptionParser::InvalidOption do
@options.parse %w[--format darkfish -r]
end
@ -315,7 +315,7 @@ rdoc_include:
end
def test_parse_formatter_ri_site
e = assert_raises OptionParser::InvalidOption do
e = assert_raise OptionParser::InvalidOption do
@options.parse %w[--format darkfish --ri-site]
end
@ -324,7 +324,7 @@ rdoc_include:
@options = RDoc::Options.new
e = assert_raises OptionParser::InvalidOption do
e = assert_raise OptionParser::InvalidOption do
@options.parse %w[--format darkfish -R]
end
@ -417,7 +417,7 @@ rdoc_include:
def test_parse_ignore_invalid_no
out, err = capture_output do
assert_raises SystemExit do
assert_raise SystemExit do
@options.parse %w[--no-ignore-invalid --bogus=arg --bobogus --visibility=extended]
end
end
@ -430,7 +430,7 @@ rdoc_include:
def test_parse_ignore_invalid_no_quiet
out, err = capture_output do
assert_raises SystemExit do
assert_raise SystemExit do
@options.parse %w[--quiet --no-ignore-invalid --bogus=arg --bobogus --visibility=extended]
end
end
@ -631,7 +631,7 @@ rdoc_include:
FileUtils.mkdir_p tmpdir
Dir.chdir tmpdir do
e = assert_raises SystemExit do
e = assert_raise SystemExit do
@options.parse %w[--write-options]
end

Просмотреть файл

@ -104,7 +104,7 @@ class TestRDocParser < RDoc::TestCase
end
def test_class_for_forbidden
omit 'chmod not supported' if Gem.win_platform?
skip 'chmod not supported' if Gem.win_platform?
tf = Tempfile.open 'forbidden' do |io|
begin

Просмотреть файл

@ -100,7 +100,7 @@ class C; end
assert_equal 'E', name_t[:text]
assert_equal 'D::E', given_name
assert_raises RDoc::Error do
assert_raise RDoc::Error do
util_parser("A::\nB").get_class_or_module ctxt
end
end

Просмотреть файл

@ -119,7 +119,7 @@ class TestRDocRDoc < RDoc::TestCase
io.write "a: !ruby.yaml.org,2002:str |\nfoo"
end
e = assert_raises RDoc::Error do
e = assert_raise RDoc::Error do
@rdoc.load_options
end
@ -163,7 +163,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_normalized_file_list_non_file_directory
dev = File::NULL
omit "#{dev} is not a character special" unless
skip "#{dev} is not a character special" unless
File.chardev? dev
files = nil
@ -349,8 +349,8 @@ class TestRDocRDoc < RDoc::TestCase
end
def test_parse_file_forbidden
omit 'chmod not supported' if Gem.win_platform?
omit "assumes that euid is not root" if Process.euid == 0
skip 'chmod not supported' if Gem.win_platform?
skip "assumes that euid is not root" if Process.euid == 0
@rdoc.store = RDoc::Store.new
@ -463,7 +463,7 @@ class TestRDocRDoc < RDoc::TestCase
Dir.mktmpdir {|path|
File.open @rdoc.output_flag_file(path), 'w' do end
e = assert_raises RDoc::Error do
e = assert_raise RDoc::Error do
@rdoc.setup_output_dir path, false
end
@ -475,7 +475,7 @@ class TestRDocRDoc < RDoc::TestCase
tf = Tempfile.open 'test_rdoc_rdoc' do |tempfile|
path = tempfile.path
e = assert_raises RDoc::Error do
e = assert_raise RDoc::Error do
@rdoc.setup_output_dir path, false
end
@ -488,7 +488,7 @@ class TestRDocRDoc < RDoc::TestCase
def test_setup_output_dir_exists_not_rdoc
Dir.mktmpdir do |dir|
e = assert_raises RDoc::Error do
e = assert_raise RDoc::Error do
@rdoc.setup_output_dir dir, false
end

Просмотреть файл

@ -751,7 +751,7 @@ Foo::Bar#bother
def test_display_name_not_found_special
util_store
assert_raises RDoc::RI::Driver::NotFoundError do
assert_raise RDoc::RI::Driver::NotFoundError do
assert_equal false, @driver.display_name('Set#[]')
end
end
@ -887,7 +887,7 @@ Foo::Bar#bother
assert_equal 'Foo', @driver.expand_class('F')
assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
assert_raises RDoc::RI::Driver::NotFoundError do
assert_raise RDoc::RI::Driver::NotFoundError do
@driver.expand_class 'F::B'
end
end
@ -903,7 +903,7 @@ Foo::Bar#bother
@store1.save
@driver.stores = [@store1]
assert_raises RDoc::RI::Driver::NotFoundError do
assert_raise RDoc::RI::Driver::NotFoundError do
@driver.expand_class 'F'
end
assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
@ -931,7 +931,7 @@ Foo::Bar#bother
assert_equal 'Foo', @driver.expand_name('F')
assert_equal 'Foo::Bar#', @driver.expand_name('F::Bar#')
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.expand_name 'Z'
end
@ -942,7 +942,7 @@ Foo::Bar#bother
assert_equal 'ruby:README', @driver.expand_name('ruby:README')
assert_equal 'ruby:', @driver.expand_name('ruby:')
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.expand_name 'nonexistent_gem:'
end
@ -1021,7 +1021,7 @@ Foo::Bar#bother
assert_equal 'gem-1.0', @driver.find_store('gem-1.0')
assert_equal 'gem-1.0', @driver.find_store('gem')
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.find_store 'nonexistent'
end
@ -1029,21 +1029,21 @@ Foo::Bar#bother
end
def test_did_you_mean
omit 'omit test with did_you_men' unless defined? DidYouMean::SpellChecker
skip 'skip test with did_you_men' unless defined? DidYouMean::SpellChecker
util_ancestors_store
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo.i_methdo'
end
assert_equal "Nothing known about Foo.i_methdo\nDid you mean? i_method", e.message
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo#i_methdo'
end
assert_equal "Nothing known about Foo#i_methdo\nDid you mean? i_method", e.message
e = assert_raises RDoc::RI::Driver::NotFoundError do
e = assert_raise RDoc::RI::Driver::NotFoundError do
@driver.lookup_method 'Foo::i_methdo'
end
assert_equal "Nothing known about Foo::i_methdo\nDid you mean? c_method", e.message
@ -1227,7 +1227,7 @@ Foo::Bar#bother
with_dummy_pager do
@driver.page do |io|
omit "couldn't find a standard pager" if io == $stdout
skip "couldn't find a standard pager" if io == $stdout
assert @driver.paging?
end
@ -1239,7 +1239,7 @@ Foo::Bar#bother
# this test is too fragile. Perhaps using Process.spawn will make this
# reliable
def _test_page_in_presence_of_child_status
omit 'this test hangs on travis-ci.org' if ENV['CI']
skip 'this test hangs on travis-ci.org' if ENV['CI']
@driver.use_stdout = false
with_dummy_pager do
@ -1407,7 +1407,7 @@ Foo::Bar#bother
pager = with_dummy_pager do @driver.setup_pager end
omit "couldn't find a standard pager" unless pager
skip "couldn't find a standard pager" unless pager
assert @driver.paging?
ensure

Просмотреть файл

@ -166,7 +166,7 @@ class TestRDocServlet < RDoc::TestCase
@req.header['if-modified-since'] = [(Time.now + 10).httpdate]
@req.path = '/ruby/Missing.html'
assert_raises WEBrick::HTTPStatus::NotModified do
assert_raise WEBrick::HTTPStatus::NotModified do
@s.do_GET @req, @res
end
end
@ -294,7 +294,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_if_modified_since
omit 'File.utime on directory not supported' if Gem.win_platform?
skip 'File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
@ -307,7 +307,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_if_modified_since_not_modified
omit 'File.utime on directory not supported' if Gem.win_platform?
skip 'File.utime on directory not supported' if Gem.win_platform?
temp_dir do
now = Time.now
@ -315,7 +315,7 @@ class TestRDocServlet < RDoc::TestCase
@req.header['if-modified-since'] = [(now + 10).httpdate]
assert_raises WEBrick::HTTPStatus::NotModified do
assert_raise WEBrick::HTTPStatus::NotModified do
@s.if_modified_since @req, @res, '.'
end
@ -490,7 +490,7 @@ class TestRDocServlet < RDoc::TestCase
def test_store_for_missing_documentation
FileUtils.mkdir_p(File.join @gem_doc_dir, 'spec-1.0', 'ri')
e = assert_raises WEBrick::HTTPStatus::NotFound do
e = assert_raise WEBrick::HTTPStatus::NotFound do
@s.store_for 'spec-1.0'
end
@ -499,7 +499,7 @@ class TestRDocServlet < RDoc::TestCase
end
def test_store_for_missing_gem
e = assert_raises WEBrick::HTTPStatus::NotFound do
e = assert_raise WEBrick::HTTPStatus::NotFound do
@s.store_for 'missing'
end