Esempio n. 1
0
    def _check_directory(self,
                         listname,
                         thing_list,
                         thing_dir,
                         thing_key,
                         ignore=[]):
        dirs = utils.git_ls_dirs()
        # get only directories directly in the thing directory
        dirs = [d for d in dirs if os.path.dirname(d) == thing_dir]
        # just the folder names
        dirs = [os.path.basename(d) for d in dirs]
        # skip the whitelist
        dirs = [d for d in dirs if d not in ignore]
        # make it a set
        dirs = set(dirs)

        # and the list of thing names
        thing_names = {thing[thing_key].split(':')[0] for thing in thing_list}

        errors = []
        # items with a directory but not a listing
        for name in dirs - thing_names:
            errors.append("Directory {}/{} exists, but isn't in {}".format(
                thing_dir, name, listname))
        for name in thing_names - dirs:
            errors.append(
                "{} exists in {}, but {}/{} isn't a directory".format(
                    name, listname, thing_dir, name))

        if errors:
            self.assertTrue(False, "\n".join(errors))
Esempio n. 2
0
 def test_init_everywhere(self):
     for folder in utils.git_ls_dirs('parlai'):
         if 'mturk' in folder:
             continue
         self.assertIn('__init__.py', os.listdir(folder),
                       '{} does not contain __init__.py'.format(folder))
Esempio n. 3
0
 def test_init_everywhere(self):
     for folder in utils.git_ls_dirs('parlai'):
         if os.path.basename(folder) == 'html':
             continue
         self.assertIn('__init__.py', os.listdir(folder),
                       '{} does not contain __init__.py'.format(folder))