1. Matt Chaput
  2. whoosh

Source

whoosh / tests / test_quality.py

Diff from to

File tests/test_quality.py

  • Ignore whitespace
 from __future__ import with_statement
 import random
 
-from nose.tools import assert_equal, assert_almost_equal  # @UnresolvedImport
-
 from whoosh import fields, matching, scoring
 from whoosh.compat import b, u, xrange
 from whoosh.filedb.filestore import RamStorage
         w.commit()
 
         with ix.reader() as r:
-            assert_equal(r.max_field_length("t"), _discreet(i))
+            assert r.max_field_length("t") == _discreet(i)
 
 
 def test_minmax_field_length():
         w.commit()
 
         with ix.reader() as r:
-            assert_equal(r.min_field_length("t"), _discreet(least))
-            assert_equal(r.max_field_length("t"), _discreet(most))
+            assert r.min_field_length("t") == _discreet(least)
+            assert r.max_field_length("t") == _discreet(most)
 
 
 def test_term_stats():
 
     with ix.reader() as r:
         ti = r.term_info("t", u("alfa"))
-        assert_equal(ti.weight(), 4.0)
-        assert_equal(ti.doc_frequency(), 2)
-        assert_equal(ti.min_length(), 4)
-        assert_equal(ti.max_length(), 5)
-        assert_equal(ti.max_weight(), 3.0)
+        assert ti.weight() == 4.0
+        assert ti.doc_frequency() == 2
+        assert ti.min_length() == 4
+        assert ti.max_length() == 5
+        assert ti.max_weight() == 3.0
 
-        assert_equal(r.term_info("t", u("echo")).min_length(), 3)
+        assert r.term_info("t", u("echo")).min_length() == 3
 
-        assert_equal(r.doc_field_length(3, "t"), 3)
-        assert_equal(r.min_field_length("t"), 3)
-        assert_equal(r.max_field_length("t"), 6)
+        assert r.doc_field_length(3, "t") == 3
+        assert r.min_field_length("t") == 3
+        assert r.max_field_length("t") == 6
 
     w = ix.writer()
     w.add_document(t=u("alfa"))
 
     with ix.reader() as r:
         ti = r.term_info("t", u("alfa"))
-        assert_equal(ti.weight(), 6.0)
-        assert_equal(ti.doc_frequency(), 4)
-        assert_equal(ti.min_length(), 1)
-        assert_equal(ti.max_length(), 7)
-        assert_equal(ti.max_weight(), 3.0)
+        assert ti.weight() == 6.0
+        assert ti.doc_frequency() == 4
+        assert ti.min_length() == 1
+        assert ti.max_length() == 7
+        assert ti.max_weight() == 3.0
 
-        assert_equal(r.term_info("t", u("echo")).min_length(), 3)
+        assert r.term_info("t", u("echo")).min_length() == 3
 
-        assert_equal(r.min_field_length("t"), 1)
-        assert_equal(r.max_field_length("t"), 7)
+        assert r.min_field_length("t") == 1
+        assert r.max_field_length("t") == 7
 
 
 def test_min_max_id():
 
     with ix.reader() as r:
         ti = r.term_info("t", u("delta"))
-        assert_equal(ti.min_id(), 1)
-        assert_equal(ti.max_id(), 3)
+        assert ti.min_id() == 1
+        assert ti.max_id() == 3
 
         ti = r.term_info("t", u("alfa"))
-        assert_equal(ti.min_id(), 0)
-        assert_equal(ti.max_id(), 0)
+        assert ti.min_id() == 0
+        assert ti.max_id() == 0
 
         ti = r.term_info("t", u("foxtrot"))
-        assert_equal(ti.min_id(), 3)
-        assert_equal(ti.max_id(), 4)
+        assert ti.min_id() == 3
+        assert ti.max_id() == 4
 
     w = ix.writer()
     w.add_document(id=5, t=u("foxtrot golf hotel"))
 
     with ix.reader() as r:
         ti = r.term_info("t", u("delta"))
-        assert_equal(ti.min_id(), 1)
-        assert_equal(ti.max_id(), 3)
+        assert ti.min_id() == 1
+        assert ti.max_id() == 3
 
         ti = r.term_info("t", u("alfa"))
-        assert_equal(ti.min_id(), 0)
-        assert_equal(ti.max_id(), 8)
+        assert ti.min_id() == 0
+        assert ti.max_id() == 8
 
         ti = r.term_info("t", u("foxtrot"))
-        assert_equal(ti.min_id(), 3)
-        assert_equal(ti.max_id(), 5)
+        assert ti.min_id() == 3
+        assert ti.max_id() == 5
 
 
 def test_replacements():
     um = matching.UnionMatcher(a, b)
 
     a2 = a.replace(0.5)
-    assert_equal(a2.__class__, matching.NullMatcherClass)
+    assert a2.__class__ == matching.NullMatcherClass
 
     um2 = um.replace(0.5)
-    assert_equal(um2.__class__, matching.IntersectionMatcher)
+    assert um2.__class__ == matching.IntersectionMatcher
     um2 = um.replace(0.6)
-    assert_equal(um2.__class__, matching.NullMatcherClass)
+    assert um2.__class__ == matching.NullMatcherClass
 
     wm = matching.WrappingMatcher(um, boost=2.0)
     wm = wm.replace(0.5)
-    assert_equal(wm.__class__, matching.WrappingMatcher)
-    assert_equal(wm.boost, 2.0)
-    assert_equal(wm.child.__class__, matching.IntersectionMatcher)
+    assert wm.__class__ == matching.WrappingMatcher
+    assert wm.boost == 2.0
+    assert wm.child.__class__ == matching.IntersectionMatcher
 
     ls1 = matching.ListMatcher([1, 2, 3], [0.1, 0.1, 0.1],
                                scorer=scoring.WeightScorer(0.1))
                                scorer=scoring.WeightScorer(0.3))
     mm = matching.MultiMatcher([ls1, ls2, ls3], [0, 4, 8])
     mm = mm.replace(0.25)
-    assert_equal(mm.current, 2)
+    assert mm.current == 2
 
     dm = matching.DisjunctionMaxMatcher(ls1, ls2)
     dm = dm.replace(0.15)