def test_directory(path): file_paths = [path + file_name for file_name in os.listdir(path)] filtered = 0; passed = 0; for current_path in file_paths: file = open(current_path, "r") text = file.read() spam_check = spam_filter.check_incoming(text) file.close() if spam_check: filtered += 1 else: passed += 1 return "Filtered: " + str(filtered) + "\nPassed: " + str(passed)
def test_file(path): file = open(path, "r") text = file.read() spam_check = spam_filter.check_incoming(text) file.close() return spam_check