Ejemplo n.º 1
0
 def test_simple_valid(self):
     with self.assertRaises(SystemExit) as context:
         main([
             os.path.join(os.path.dirname(__file__), 'data',
                          'simple_valid.po')
         ])
     self.assertEqual(context.exception.code, 0)
Ejemplo n.º 2
0
 def test_header_only(self):
     with self.assertRaises(SystemExit) as context:
         main([
             os.path.join(os.path.dirname(__file__), 'data',
                          'header_only.po')
         ])
     self.assertEqual(context.exception.code, 0)
Ejemplo n.º 3
0
 def test_ignore_all(self):
     # Ignore multiple errors
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         cmd = [os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'), '--ignore',
                'untranslated,location,fuzzy,obsolete,unsorted']
         main(cmd, output=output)
     self.assertEqual(context.exception.code, 0)
Ejemplo n.º 4
0
 def test_ignore_untranslated(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'), '--ignore', 'untranslated'],
              output=output)
     self.assertEqual(context.exception.code, 1)
     self.assertIn('invalid.po:13: [fuzzy] translation is fuzzy\n', output.getvalue())
     self.assertIn('invalid.po:17: [obsolete] entry is obsolete\n', output.getvalue())
     self.assertNotIn(': [untranslated] ', output.getvalue())
Ejemplo n.º 5
0
 def test_show_msg(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'), '--show-msg'], output=output)
     self.assertEqual(context.exception.code, 1)
     location_output = 'invalid.po:23: [unsorted] entry is not sorted\n' \
                       '#: source.file:42\n' \
                       'msgid "Location"\n' \
                       'msgstr "Location"\n'
     self.assertIn(location_output, output.getvalue())
Ejemplo n.º 6
0
 def test_ignore_all(self):
     # Ignore multiple errors
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         cmd = [
             os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'),
             '--ignore', 'untranslated,location,fuzzy,obsolete,unsorted'
         ]
         main(cmd, output=output)
     self.assertEqual(context.exception.code, 0)
Ejemplo n.º 7
0
 def test_invalid(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([os.path.join(os.path.dirname(__file__), 'data', 'invalid.po')], output=output)
     self.assertEqual(context.exception.code, 1)
     self.assertIn('invalid.po:13: [fuzzy] translation is fuzzy\n', output.getvalue())
     self.assertIn('invalid.po:13: [untranslated] translation is missing\n', output.getvalue())
     self.assertIn('invalid.po:17: [obsolete] entry is obsolete\n', output.getvalue())
     self.assertIn('invalid.po:17: [untranslated] translation is missing\n', output.getvalue())
     self.assertIn('invalid.po:20: [untranslated] translation is missing\n', output.getvalue())
     self.assertIn('invalid.po:23: [location] entry contains location\n', output.getvalue())
Ejemplo n.º 8
0
 def test_show_msg(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([
             os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'),
             '--show-msg'
         ],
              output=output)
     self.assertEqual(context.exception.code, 1)
     location_output = 'invalid.po:23: [unsorted] entry is not sorted\n' \
                       '#: source.file:42\n' \
                       'msgid "Location"\n' \
                       'msgstr "Location"\n'
     self.assertIn(location_output, output.getvalue())
Ejemplo n.º 9
0
 def test_ignore_untranslated(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([
             os.path.join(os.path.dirname(__file__), 'data', 'invalid.po'),
             '--ignore', 'untranslated'
         ],
              output=output)
     self.assertEqual(context.exception.code, 1)
     self.assertIn('invalid.po:13: [fuzzy] translation is fuzzy\n',
                   output.getvalue())
     self.assertIn('invalid.po:17: [obsolete] entry is obsolete\n',
                   output.getvalue())
     self.assertNotIn(': [untranslated] ', output.getvalue())
Ejemplo n.º 10
0
 def test_invalid(self):
     output = StringIO()
     with self.assertRaises(SystemExit) as context:
         main([
             os.path.join(os.path.dirname(__file__), 'data', 'invalid.po')
         ],
              output=output)
     self.assertEqual(context.exception.code, 1)
     self.assertIn('invalid.po:13: [fuzzy] translation is fuzzy\n',
                   output.getvalue())
     self.assertIn('invalid.po:13: [untranslated] translation is missing\n',
                   output.getvalue())
     self.assertIn('invalid.po:17: [obsolete] entry is obsolete\n',
                   output.getvalue())
     self.assertIn('invalid.po:17: [untranslated] translation is missing\n',
                   output.getvalue())
     self.assertIn('invalid.po:20: [untranslated] translation is missing\n',
                   output.getvalue())
     self.assertIn('invalid.po:23: [location] entry contains location\n',
                   output.getvalue())
Ejemplo n.º 11
0
 def test_multiple_valid_files(self):
     with self.assertRaises(SystemExit) as context:
         main([os.path.join(os.path.dirname(__file__), 'data', 'simple_valid.po'),
               os.path.join(os.path.dirname(__file__), 'data', 'header_only.po')])
     self.assertEqual(context.exception.code, 0)
Ejemplo n.º 12
0
 def test_empty(self):
     with self.assertRaises(SystemExit) as context:
         main([os.path.join(os.path.dirname(__file__), 'data', 'empty.po')])
     self.assertEqual(context.exception.code, 0)