Changeset: 0e68be865954 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0e68be865954 Modified Files: common/stream/Tests/read_tests.py common/stream/Tests/testdata.py Branch: makelibstreamgreatagain Log Message:
Generate testdata to stdout if required for manual testing diffs (57 lines): diff --git a/common/stream/Tests/read_tests.py b/common/stream/Tests/read_tests.py --- a/common/stream/Tests/read_tests.py +++ b/common/stream/Tests/read_tests.py @@ -94,6 +94,15 @@ def all_tests(filename_filter): if __name__ == "__main__": - docname = "small.txt.gz" - doc = [d for d in gen_docs()][0] - test_read('rastream', True, doc) + # generate test data for manual testing + if len(sys.argv) == 1: + for d in gen_docs(): + print(d.name) + elif len(sys.argv) == 2: + for d in gen_docs(): + if d.name == sys.argv[1]: + d.write(sys.stdout.buffer) + else: + print("Usage: python3 read_tests.py [TESTDATANAME]", file=sys.stderr) + sys.exit(1) + diff --git a/common/stream/Tests/testdata.py b/common/stream/Tests/testdata.py --- a/common/stream/Tests/testdata.py +++ b/common/stream/Tests/testdata.py @@ -51,18 +51,23 @@ class Doc: if length_limit != None: self.content = self.content[:length_limit] - # not sure if this is the right API - def write(self, filename): + def write(self, filename_or_fileobj): + if hasattr(filename_or_fileobj, "write"): + filename = None + fileobj = filename_or_fileobj + else: + filename = filename_or_fileobj + fileobj = open(filename, 'wb') if not self.compression: - f = open(filename, 'wb') + f = fileobj elif self.compression == 'gz': - f = gzip.GzipFile(filename, 'wb', mtime=131875200, compresslevel=1) + f = gzip.GzipFile(filename, 'wb', fileobj=fileobj, mtime=131875200, compresslevel=1) elif self.compression == 'bz2': - f = bz2.BZ2File(filename, 'wb', compresslevel=1) + f = bz2.BZ2File(fileobj, 'wb', compresslevel=1) elif self.compression == 'xz': - f = lzma.LZMAFile(filename, 'wb', preset=1) - elif self.compression == 'lz4': - f = lz4.frame.LZ4FrameFile(filename, 'wb', compression_level=1) + f = lzma.LZMAFile(fileobj, 'wb', preset=1) + elif self.compression == 'lz4': # ok + f = lz4.frame.LZ4FrameFile(fileobj, 'wb', compression_level=1) else: raise Exception("Unknown compression scheme: " + self.compression) f.write(self.content) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list