From a8ec99a84861e94a3b1bc81dff2b77ac63faf3da Mon Sep 17 00:00:00 2001 From: Yusuke Shinyama Date: Sun, 15 Jun 2014 10:52:59 +0900 Subject: [PATCH] More autotest tweaks. --- Makefile | 9 +++------ pdfminer/layout.py | 8 ++++---- samples/nonfree/f1040nr.html.ref | 4 ++-- samples/nonfree/f1040nr.xml.ref | 16 ++++++++-------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index ad54e28..04729aa 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,9 @@ clean: -$(RM) -r build dist MANIFEST -cd $(PACKAGE) && $(MAKE) clean -cd tools && $(MAKE) clean + -cd samples && $(MAKE) clean -distclean: clean test_clean cmap_clean +distclean: clean cmap_clean sdist: distclean MANIFEST.in $(PYTHON) setup.py sdist @@ -53,7 +54,7 @@ $(CMAPDST)/to-unicode-Adobe-Korea1.pickle.gz: $(CMAPDST) $(CONV_CMAP) -c KSC-EUC=euc-kr -c KSC-Johab=johab -c KSCms-UHC=cp949 -c UniKS-UTF8=utf-8 \ $(CMAPDST) Adobe-Korea1 $(CMAPSRC)/cid2code_Adobe_Korea1.txt -unittest: +test: cmap $(PYTHON) -m doctest \ pdfminer/arcfour.py \ pdfminer/lzw.py \ @@ -62,8 +63,4 @@ unittest: pdfminer/rijndael.py $(PYTHON) pdfminer/ccitt.py $(PYTHON) pdfminer/psparser.py - -test: cmap cd samples && $(MAKE) clean test -test_clean: - -cd samples && $(MAKE) clean diff --git a/pdfminer/layout.py b/pdfminer/layout.py index 9bb836d..99807b2 100644 --- a/pdfminer/layout.py +++ b/pdfminer/layout.py @@ -615,7 +615,8 @@ class LTLayoutContainer(LTContainer): for j in xrange(i+1, len(boxes)): obj2 = boxes[j] dists.append((0, dist(obj1, obj2), obj1, obj2)) - dists.sort() + # We could use dists.sort(), but it would randomize the test result. + dists = csort(dists) plane = Plane(self.bbox) plane.extend(boxes) while dists: @@ -630,11 +631,10 @@ class LTLayoutContainer(LTContainer): group = LTTextGroupLRTB([obj1, obj2]) plane.remove(obj1) plane.remove(obj2) - # this line is optimized -- don't change without profiling - dists = [n for n in dists if n[2] in plane._objs and n[3] in plane._objs] + dists = [ n for n in dists if (n[2] in plane and n[3] in plane) ] for other in plane: dists.append((0, dist(group, other), group, other)) - dists.sort() + dists = csort(dists) plane.add(group) assert len(plane) == 1 return list(plane) diff --git a/samples/nonfree/f1040nr.html.ref b/samples/nonfree/f1040nr.html.ref index 53f117c..e0d71fb 100644 --- a/samples/nonfree/f1040nr.html.ref +++ b/samples/nonfree/f1040nr.html.ref @@ -269,9 +269,9 @@
Taxable amount (see page 13)

22 -
-

+
+



diff --git a/samples/nonfree/f1040nr.xml.ref b/samples/nonfree/f1040nr.xml.ref index 40656d2..533d951 100644 --- a/samples/nonfree/f1040nr.xml.ref +++ b/samples/nonfree/f1040nr.xml.ref @@ -4983,16 +4983,16 @@ - - - + + + - - - + + + @@ -5967,9 +5967,9 @@ - + - +