Esempio n. 1
0
 def test_check_explicit_underscore_import(self):
     self.assertEqual(1, len(list(checks.check_explicit_underscore_import(
         "LOG.info(_('My info message'))",
         "cinder/tests/other_files.py"))))
     self.assertEqual(1, len(list(checks.check_explicit_underscore_import(
         "msg = _('My message')",
         "cinder/tests/other_files.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "from cinder.i18n import _",
         "cinder/tests/other_files.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "LOG.info(_('My info message'))",
         "cinder/tests/other_files.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "msg = _('My message')",
         "cinder/tests/other_files.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "from cinder.i18n import _, _LW",
         "cinder/tests/other_files2.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "msg = _('My message')",
         "cinder/tests/other_files2.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "_ = translations.ugettext",
         "cinder/tests/other_files3.py"))))
     self.assertEqual(0, len(list(checks.check_explicit_underscore_import(
         "msg = _('My message')",
         "cinder/tests/other_files3.py"))))
Esempio n. 2
0
 def test_check_explicit_underscore_import(self):
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))",
                     "cinder/tests/other_files.py"))), 1)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "cinder/tests/other_files.py"))), 1)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from cinder.i18n import _",
                     "cinder/tests/other_files.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))",
                     "cinder/tests/other_files.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "cinder/tests/other_files.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from cinder.i18n import _, _LW",
                     "cinder/tests/other_files2.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "cinder/tests/other_files2.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "_ = translations.ugettext",
                     "cinder/tests/other_files3.py"))), 0)
     self.assertEqual(
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "cinder/tests/other_files3.py"))), 0)
Esempio n. 3
0
 def test_check_explicit_underscore_import(self):
     self.assertEqual(
         1,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))", "manila/tests/other_files.py"
                 )
             )
         ),
     )
     self.assertEqual(
         1,
         len(list(checks.check_explicit_underscore_import("msg = _('My message')", "manila/tests/other_files.py"))),
     )
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import("from manila.i18n import _", "manila/tests/other_files.py")
             )
         ),
     )
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))", "manila/tests/other_files.py"
                 )
             )
         ),
     )
     self.assertEqual(
         0,
         len(list(checks.check_explicit_underscore_import("msg = _('My message')", "manila/tests/other_files.py"))),
     )
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from manila.i18n import _LE, _, _LW", "manila/tests/other_files2.py"
                 )
             )
         ),
     )
     self.assertEqual(
         0,
         len(list(checks.check_explicit_underscore_import("msg = _('My message')", "manila/tests/other_files2.py"))),
     )
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import("_ = translations.ugettext", "manila/tests/other_files3.py")
             )
         ),
     )
     self.assertEqual(
         0,
         len(list(checks.check_explicit_underscore_import("msg = _('My message')", "manila/tests/other_files3.py"))),
     )
     # Complete code coverage by falling through all checks
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info('My info message')", "manila.tests.unit/other_files4.py"
                 )
             )
         ),
     )
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from manila.i18n import _LW", "manila.tests.unit/other_files5.py"
                 )
             )
         ),
     )
     self.assertEqual(
         1,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')", "manila.tests.unit/other_files5.py"
                 )
             )
         ),
     )
Esempio n. 4
0
 def test_check_explicit_underscore_import(self):
     self.assertEqual(
         1,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))",
                     "manila/tests/other_files.py"))))
     self.assertEqual(
         1,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "manila/tests/other_files.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from manila.i18n import _",
                     "manila/tests/other_files.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info(_('My info message'))",
                     "manila/tests/other_files.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "manila/tests/other_files.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from manila.i18n import _LE, _, _LW",
                     "manila/tests/other_files2.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "manila/tests/other_files2.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "_ = translations.ugettext",
                     "manila/tests/other_files3.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "manila/tests/other_files3.py"))))
     # Complete code coverage by falling through all checks
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "LOG.info('My info message')",
                     "manila.tests.unit/other_files4.py"))))
     self.assertEqual(
         0,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "from manila.i18n import _LW",
                     "manila.tests.unit/other_files5.py"))))
     self.assertEqual(
         1,
         len(
             list(
                 checks.check_explicit_underscore_import(
                     "msg = _('My message')",
                     "manila.tests.unit/other_files5.py"))))