def suite(): s = unittest.TestSuite() # General tests. for kind, tagsets in test_files.items(): for tagset in tagsets: path = os.path.join(_common.RSRC, tagset + '.' + kind) correct_dict = correct_dicts[tagset] for test in suite_for_file(path, correct_dict): s.addTest(test) # Special test for missing ID3 tag. for test in suite_for_file(os.path.join(_common.RSRC, 'empty.mp3'), correct_dicts['empty'], writing=False): s.addTest(test) # Special test for advanced release date. for test in suite_for_file(os.path.join(_common.RSRC, 'date.mp3'), correct_dicts['date']): s.addTest(test) # Read-only attribute tests. for fname, correct_dict in read_only_correct_dicts.iteritems(): path = os.path.join(_common.RSRC, fname) for field, value in correct_dict.iteritems(): s.addTest(MakeReadOnlyTest(path, field, value)()) return s
def suite(): s = unittest.TestSuite() # Get the suite() of every module in this directory beginning with # "test_". for fname in os.listdir(pkgpath): match = re.match(r'(test_\S+)\.py$', fname) if match: modname = match.group(1) s.addTest(__import__(modname).suite()) return s
def suite_for_file(path, correct_dict, writing=True): s = unittest.TestSuite() for field in correct_dict: if 'm4a' in path and field.startswith('rg_'): # MPEG-4 files: ReplayGain values not implemented. continue s.addTest(MakeReadingTest(path, correct_dict, field)()) if writing and \ not ( field == 'month' and correct_dict['year'] == 0 or field == 'day' and correct_dict['month'] == 0): # ensure that we don't test fields that can't be modified s.addTest(MakeWritingTest(path, correct_dict, field)()) return s