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

0 views
Skip to first unread message

Kouhei Sutou

unread,
Jun 16, 2018, 6:45:03 PM6/16/18
to ruby-gett...@googlegroups.com
Author
Kouhei Sutou <k...@clear-code.com>
Date
2018-06-17 07:44:38 +0900 (Sun, 17 Jun 2018)
New Revision
a5a6d33576308299a33293d659a128d16ccb3f8c
Message
test: suppress expected warnings
Modified files
  Modified: test/test_string.rb (+16 -3)
===================================================================
...
2
3
4
 
 
 
 
 
 
 
 
 
5
6
7
...
22
23
24
25
 
 
 
26
27
28
...
30
31
32
33
34
 
 
 
 
35
36
37
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
31
32
33
 
34
35
36
37
38
39
...
41
42
43
 
 
44
45
46
47
48
49
50
@@ -2,6 +2,15 @@
 
 class TestGetTextString < Test::Unit::TestCase
   class TestFormat < self
+    def suppress_warning
+      stderr, $stderr = $stderr, StringIO.new
+      begin
+        yield
+      ensure
+        $stderr = stderr
+      end
+    end
+
     def test_basic
       assert_equal("foo is a number", "%{msg} is a number" % {:msg => "foo"})
       assert_equal("bar is a number", "%s is a number" % ["bar"])
@@ -22,7 +31,9 @@ class TestGetTextString < Test::Unit::TestCase
 
     def test_percent
       assert_equal("% 1", "%% %<num>d" % {:num => 1.0})
-      assert_equal("%{num} %<num>d", "%%{num} %%<num>d" % {:num => 1})
+      suppress_warning do
+        assert_equal("%{num} %<num>d", "%%{num} %%<num>d" % {:num => 1})
+      end
     end
 
     def test_percent_in_replacement
@@ -30,8 +41,10 @@ class TestGetTextString < Test::Unit::TestCase
     end
 
     def test_no_placeholder
-      assert_equal("aaa", "aaa" % {:num => 1})
-      assert_equal("bbb", "bbb" % [1])
+      suppress_warning do
+        assert_equal("aaa", "aaa" % {:num => 1})
+        assert_equal("bbb", "bbb" % [1])
+      end
     end
 
     def test_ruby19_style
Reply all
Reply to author
Forward
0 new messages