Exemple #1
0
 def test_find_config_local_config(self):
     # Test that when a config file is found is current directory, it is
     # used as the config file
     temp_directory = self.useFixture(fixtures.TempDir()).path
     os.chdir(temp_directory)
     local_config = "./bandit.yaml"
     with open(local_config, 'wt') as fd:
         fd.write(bandit_config_content)
     self.assertEqual(local_config, bandit._find_config())
Exemple #2
0
    def _test(self, directory_with_config=None, user_config_dir=None,
              site_config_dir=None):

        user_config_dir = user_config_dir or self.getUniqueString()
        site_config_dir = site_config_dir or self.getUniqueString()

        self.useFixture(
            fixtures.MockPatch('appdirs.user_config_dir',
                               return_value=user_config_dir))
        self.useFixture(
            fixtures.MockPatch('appdirs.site_config_dir',
                               return_value=site_config_dir))

        def is_current_config(arg):
            if not directory_with_config:
                return False
            return arg == (directory_with_config + BASE_CONFIG)

        self.useFixture(
            fixtures.MockPatch('os.path.isfile', is_current_config))

        found_config = bandit._find_config()
        exp_config = directory_with_config + BASE_CONFIG
        self.assertEqual(exp_config, found_config)