def fragment(*args): stdout = fragment_to_stdout(*args) try: reader = fragment_io.read_fragment_records(StringIO(stdout)) return (reader, list(reader)) except Exception as err: raise AssertionError("Error parsing results of %r: %s" % (args, err))
def test_output_to_fragments(self): dirname, filename = create_testdir_and_filename( self, "output.fragments") fragment_to_stdout(SPACE_SMI, "--output", filename, "--delimiter", "to-eol") reader = fragment_io.read_fragment_records(filename) records = list(reader) self._check_record(records[0], "record 1", "Oc1ccccc1O")
def test_output_to_fragments_gz(self): dirname, filename = create_testdir_and_filename(self, "output.fragments.gz") fragment_to_stdout(SPACE_SMI, "--output", filename, "--delimiter", "to-eol") with open(filename, "rb") as infile: text = infile.read(4) self.assertEqual(text, b"\x1f\x8b\x08\x08") reader = fragment_io.read_fragment_records(filename) records = list(reader) self._check_record(records[0], "record 1", "Oc1ccccc1O")