コード例 #1
0
ファイル: test_hacking.py プロジェクト: anantk/nova
    def test_no_setting_conf_directly_in_tests(self):
        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.option = 1", "nova/tests/test_foo.py"))), 1
        )

        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.group.option = 1", "nova/tests/test_foo.py"))), 1
        )

        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.option = foo = 1", "nova/tests/test_foo.py"))), 1
        )

        # Shouldn't fail with comparisons
        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.option == 'foo'", "nova/tests/test_foo.py"))), 0
        )

        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.option != 1", "nova/tests/test_foo.py"))), 0
        )

        # Shouldn't fail since not in nova/tests/
        self.assertEqual(
            len(list(checks.no_setting_conf_directly_in_tests("CONF.option = 1", "nova/compute/foo.py"))), 0
        )
コード例 #2
0
    def test_no_setting_conf_directly_in_tests(self):
        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.option = 1", "nova/tests/test_foo.py"))), 1)

        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.group.option = 1", "nova/tests/test_foo.py"))), 1)

        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.option = foo = 1", "nova/tests/test_foo.py"))), 1)

        # Shouldn't fail with comparisons
        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.option == 'foo'", "nova/tests/test_foo.py"))), 0)

        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.option != 1", "nova/tests/test_foo.py"))), 0)

        # Shouldn't fail since not in nova/tests/
        self.assertEqual(len(list(checks.no_setting_conf_directly_in_tests(
            "CONF.option = 1", "nova/compute/foo.py"))), 0)