ruby-gettext/gettext@a075a60 [master] test: suppress expected warnings

1 view
Skip to first unread message

Kouhei Sutou

unread,
Jun 16, 2018, 6:49:14 PM6/16/18
to ruby-gett...@googlegroups.com
Author
Kouhei Sutou <k...@clear-code.com>
Date
2018-06-17 07:48:39 +0900 (Sun, 17 Jun 2018)
New Revision
a075a60d348771d06102cf287cb55c51b70d9f8e
Message
test: suppress expected warnings
Modified files
  Modified: test/gettext-test-utils.rb (+10 -3)
===================================================================
...
1
2
3
 
4
5
6
...
41
42
43
 
 
 
 
 
 
 
 
 
44
...
 
 
 
1
2
3
4
...
39
40
41
42
43
44
45
46
47
48
49
50
51
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012-2013  Kouhei Sutou <k...@clear-code.com>
+# Copyright (C) 2012-2018  Kouhei Sutou <k...@clear-code.com>
 #
 # License: Ruby's or LGPL
 #
@@ -41,4 +39,13 @@ module GetTextTestUtils
   def teardown_tmpdir
     FileUtils.rm_rf(@tmpdir, :secure => true) if @tmpdir
   end
+
+  def suppress_warning
+    stderr, $stderr = $stderr, StringIO.new
+    begin
+      yield
+    ensure
+      $stderr = stderr
+    end
+  end
 end
  Modified: test/test_po_parser.rb (+6 -4)
===================================================================
...
1
2
3
 
4
5
6
...
62
63
64
 
 
65
66
67
...
220
221
222
223
 
 
 
224
225
226
...
 
 
 
1
2
3
4
...
60
61
62
63
64
65
66
67
...
220
221
222
 
223
224
225
226
227
228
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012  Kouhei Sutou <k...@clear-code.com>
+# Copyright (C) 2012-2018  Kouhei Sutou <k...@clear-code.com>
 # Copyright (C) 2012  Haruka Yoshihara <yosh...@clear-code.com>
 #
 # License: Ruby's or LGPL
@@ -62,6 +60,8 @@ EOP
   end
 
   class TestPO < self
+    include GetTextTestUtils
+
     def test_msgstr
       po_file = create_po_file(<<-EOP)
 # This is the comment.
@@ -220,7 +220,9 @@ EOP
 msgid "hello"
 msgstr "bonjour"
 EOP
-      entries = parse_po_file(po_file, :ignore_fuzzy => false)
+      entries = suppress_warning do
+        parse_po_file(po_file, :ignore_fuzzy => false)
+      end
 
       assert_true(entries.has_key?("hello"))
       assert_equal("fuzzy", entries["hello"].flag)
  Modified: test/test_string.rb (+1 -10)
===================================================================
...
1
2
3
4
5
6
7
8
9
10
11
12
 
13
14
15
...
 
 
1
2
 
 
 
 
 
 
 
 
3
4
5
6
@@ -1,15 +1,6 @@
-# -*- coding: utf-8 -*-
-
 class TestGetTextString < Test::Unit::TestCase
   class TestFormat < self
-    def suppress_warning
-      stderr, $stderr = $stderr, StringIO.new
-      begin
-        yield
-      ensure
-        $stderr = stderr
-      end
-    end
+    include GetTextTestUtils
 
     def test_basic
       assert_equal("foo is a number", "%{msg} is a number" % {:msg => "foo"})
Reply all
Reply to author
Forward
0 new messages