Пример #1
0
    def test_check_wrong_logging_import(self):
        bad_imports = ["from oslo_log import log", "import oslo_log", "import logging"]
        good_imports = ["from rally.common import log", "from rally.common.log", "import rally.common.log"]

        for bad_import in bad_imports:
            checkres = checks.check_import_of_logging(bad_import, "fakefile")
            self.assertIsNotNone(next(checkres))

        for bad_import in bad_imports:
            checkres = checks.check_import_of_logging(bad_import, "./rally/common/log.py")
            self.assertEqual([], list(checkres))

        for good_import in good_imports:
            checkres = checks.check_import_of_logging(good_import, "fakefile")
            self.assertEqual([], list(checkres))
Пример #2
0
    def test_check_wrong_logging_import(self):
        bad_imports = ["from oslo_log import log",
                       "import oslo_log",
                       "import logging"]
        good_imports = ["from rally.common import logging",
                        "from rally.common.logging",
                        "import rally.common.logging"]

        for bad in bad_imports:
            checkres = checks.check_import_of_logging(bad, bad, "fakefile")
            self.assertIsNotNone(next(checkres))

        for bad in bad_imports:
            checkres = checks.check_import_of_logging(
                bad, bad, "./rally/common/logging.py")
            self.assertEqual([], list(checkres))

        for good in good_imports:
            checkres = checks.check_import_of_logging(good, good, "fakefile")
            self.assertEqual([], list(checkres))
Пример #3
0
    def test_check_wrong_logging_import(self):
        fake_imports = ["from rally.openstack.common import log",
                        "import rally.openstack.common.log"
                        "import logging"]
        good_imports = ["from rally import log",
                        "from rally.log",
                        "import rally.log"]

        for fake_import in fake_imports:
            checkres = checks.check_import_of_logging(fake_import, "fakefile")
            self.assertIsNotNone(next(checkres))

        for fake_import in fake_imports:
            checkres = checks.check_import_of_logging(fake_import,
                                                      "./rally/log.py")
            self.assertEqual([], list(checkres))

        for fake_import in good_imports:
            checkres = checks.check_import_of_logging(fake_import,
                                                      "fakefile")
            self.assertEqual([], list(checkres))