def test_invalidGet(self): searchpath = os.path.join(self.temp_dir, "*abc") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=TestPathMatchInfoGroup, subargs={"searchpath": self.temp_dir}) cls.generate() cls.update() outdict = cls.get() self.assertEqual(outdict, {}) self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(cls.searchpath, searchpath)
def test_validGetInvalidClass(self): searchpath = os.path.join(self.temp_dir, "*") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=unittest.TestCase, subargs={"searchpath": self.temp_dir}) try: cls.generate() except: pass cls.update() outdict = cls.get() self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(outdict, {})
def test_validGet(self): searchpath = os.path.join(self.temp_dir, "*") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=TestPathMatchInfoGroup, subargs={"searchpath": self.temp_dir}) cls.generate() cls.update() outdict = cls.get() self.assertEqual(cls._data, {}) for inst in cls._instances: self.assertEqual(inst._instances, []) self.assertNotEqual(inst._data, {}) for i, key in enumerate(self.temp_files.keys()): for subkey in outdict[key]: self.assertEqual(key, subkey) self.assertEqual(key, outdict[key][subkey])