Exemple #1
0
    def test_iglob(self):
        expected = [path.join(self.dir, x) for x in ['a', 'b', 'c', 'd']]
        actual = glob.iglob(path.join(self.dir, '**'))
        self.assertIsInstance(actual, types.GeneratorType)
        actual = list(actual)
        self.assertCountEqual(expected, actual)

        actual2 = glob.iglob(path.join(self.dir, '*'))
        self.assertIsInstance(actual2, types.GeneratorType)
        actual2 = list(actual2)
        self.assertEqual(actual, actual2)
Exemple #2
0
def build_all():
    for filename in glob.iglob("/var/local/submitty/to_be_built/*.json"):
        with open(filename) as data_file:
            print("going to process: " + filename)
            data = json.load(data_file)
            # after loading the contents of the file, remove it first
            os.remove(filename)
            # then build it, because build is slow (and we might have a race condition)
            build_one(data)
            print("finished with " + filename)
Exemple #3
0
 def test_iglob_recursive(self):
     expected = [
         '', 'a', 'b', 'c', 'd',
         path.join('c', 'e'),
         path.join('d', 'f'),
         path.join('d', 'f', 'g')
     ]
     expected = [path.join(self.dir, x) for x in expected]
     actual = glob.iglob(path.join(self.dir, '**'), recursive=True)
     self.assertIsInstance(actual, types.GeneratorType)
     self.assertCountEqual(expected, list(actual))