def load_suite_from_file(self, filename): """Load a test suite with test lines from the provided TAP file. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() rules = Rules(filename, suite) if not os.path.exists(filename): rules.handle_file_does_not_exist() return suite line_counter = 0 for line in self._parser.parse_file(filename): line_counter += 1 if line.category in self.ignored_lines: continue if line.category == 'test': suite.addTest(Adapter(filename, line)) rules.saw_test() elif line.category == 'plan': if line.skip: rules.handle_skipping_plan(line) return suite rules.saw_plan(line, line_counter) elif line.category == 'bail': rules.handle_bail(line) return suite elif line.category == 'version': rules.saw_version_at(line_counter) rules.check(line_counter) return suite