changeset 45:212da3fe3b19

make test 1 idempotent
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 05 Jul 2023 19:32:02 +0100
parents 083229195d12
children 44d3a4f4ea51
files bin/test_warc.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bin/test_warc.py	Wed Jul 05 17:51:44 2023 +0100
+++ b/bin/test_warc.py	Wed Jul 05 19:32:02 2023 +0100
@@ -6,12 +6,18 @@
   sys.argv.pop(1)
 
 def showme(wtype,buf,part):
+  # This should exactly reproduce a complete warc file if called
+  #  as per version 1 below
   if debug:
-    breakpoint()
-  OUT.write(b"%d\n%b"%(part,buf))
-
+    OUT.write(b"%d\n%b"%(part,buf))
+  else:
+    OUT.write(buf)
+    if buf[-1]!=b'\n':
+      OUT.write(b'\r\n')
+    if part==7:
+      OUT.write(b'\r\n') # to match complete file formatting
 
-#warc(showme,[b'response','warcinfo','request','metadata'],int(sys.argv[2]))
-#warc(showme,[b'response'],whole=True)
+# 1 warc.warc(sys.argv[1],showme,[b'response','warcinfo','request','metadata'],whole=True)
 
+# 2
 warc.warc(sys.argv[1],showme,[b'response'],parts=int(sys.argv[2]),debug=debug)