Commits

Matt Chaput  committed 3a53d12

Removed unused imports.

  • Participants
  • Parent commits 7a6e56f

Comments (0)

Files changed (14)

File tests/test_dateparse.py

-from datetime import datetime
-
 from nose.tools import assert_equal  #@UnresolvedImport
 
 from whoosh.qparser.dateparse import *

File tests/test_fields.py

 from nose.tools import assert_equal, assert_not_equal, assert_raises  #@UnresolvedImport
 
 from whoosh import fields, qparser, query
-from whoosh.compat import long_type, u, b, xrange, PY3
+from whoosh.compat import long_type, u, b, xrange
 from whoosh.filedb.filestore import RamStorage
 from whoosh.support import times
 

File tests/test_matching.py

 from nose.tools import assert_equal, assert_not_equal  #@UnresolvedImport
 
 from whoosh import fields
-from whoosh.compat import xrange, next, u
+from whoosh.compat import u
 from whoosh.filedb.filestore import RamStorage
 from whoosh.matching import *
 from whoosh.query import And, Term

File tests/test_parse_plugins.py

 
 def _plugin_classes(ignore):
     # Get all the subclasses of Plugin in whoosh.qparser.plugins
-    return [c for name, c in inspect.getmembers(plugins, inspect.isclass)
+    return [c for _, c in inspect.getmembers(plugins, inspect.isclass)
             if plugins.Plugin in c.__bases__ and c not in ignore]
 
 

File tests/test_parsing.py

 from __future__ import print_function
 
-from nose.tools import assert_equal, assert_not_equal  #@UnresolvedImport
+from nose.tools import assert_equal  #@UnresolvedImport
 
 from whoosh import analysis, fields, query
 from whoosh.compat import u, text_type

File tests/test_pool.py

-from nose.tools import assert_equal  #@UnresolvedImport
-
-from whoosh import fields
-from whoosh.filedb import pools, filestore
-
-
-class FakeTermIndex(object):
-    def __init__(self):
-        self.d = {}
-    
-    def add(self, term, info):
-        fieldname, text = term
-        weight, offset, postcount = info
-        self.d[term] = info
-    
-    def __getattr__(self, name):
-        raise Exception("FTI name=%s" % name)
-    
-
-class FakePostWriter(object):
-    def __init__(self):
-        self.l = []
-        self.blockcount = 0
-        self.blockids = self.blockweights = self.blockvalues = []
-    
-    def start(self, format):
-        self.ps = []
-        return len(self.l)
-        
-    def write(self, *args):
-        self.ps.append(args)
-    
-    def finish(self):
-        return len(self.ps)
-    
-    def cancel(self):
-        pass
-    
-    def as_inline(self):
-        return ([], [], [], None, None)
-    
-    @property
-    def posttotal(self):
-        return len(self.ps)
-    
-    def __getattr__(self, name):
-        raise Exception("FPW name=%s" % name)
-
-
-#def test_addpostings():
-#    s = fields.Schema(text=fields.TEXT)
-#    st = filestore.RamStorage()
-#    
-#    p = pools.TempfilePool(s)
-#    p.add_posting("text", u"alfa", 0, 1.0, "\x00\x00\x00\x01")
-#    p.add_posting("text", u"bravo", 0, 2.0, "\x00\x00\x00\x02")
-#    p.add_posting("text", u"charlie", 0, 3.0, "\x00\x00\x00\x03")
-#    p.add_field_length(0, "text", 6)
-#    p.add_posting("text", u"bravo", 1, 4.0, "\x00\x00\x00\x04")
-#    p.add_posting("text", u"charlie", 1, 5.0, "\x00\x00\x00\x05")
-#    p.add_posting("text", u"delta", 1, 6.0, "\x00\x00\x00\x06")
-#    p.add_field_length(1, "text", 15)
-#    
-#    p.dump_run()
-#    
-#    doccount = 2
-#    lengthfile = st.create_file("test.len")
-#    termtable = FakeTermIndex()
-#    postwriter = FakePostWriter()
-#    
-#    p.finish(doccount, lengthfile, termtable, postwriter)
-
-
-
-

File tests/test_quality.py

 from __future__ import with_statement
 import random
 
-from nose.tools import assert_equal, assert_almost_equal, assert_not_equal
+from nose.tools import assert_equal, assert_almost_equal  #@UnresolvedImport
 
-from whoosh import analysis, fields, formats, matching, scoring
+from whoosh import fields, formats, matching, scoring
 from whoosh.compat import b, u, xrange
-from whoosh.filedb.filepostings import FilePostingWriter, FilePostingReader
+from whoosh.filedb.filepostings import FilePostingWriter
 from whoosh.filedb.filestore import RamStorage
 from whoosh.filedb.filetables import FileTermInfo
 from whoosh.filedb.postblocks import current

File tests/test_ramindex.py

 from __future__ import with_statement
 
-from nose.tools import assert_equal, assert_raises
+from nose.tools import assert_equal, assert_raises  #@UnresolvedImport
 
 from whoosh import analysis, fields, formats, query
 from whoosh.compat import u, xrange, text_type

File tests/test_reading.py

 from __future__ import with_statement
 import random, threading, time
 
-from nose.tools import assert_equal
+from nose.tools import assert_equal  #@UnresolvedImport
 
 from whoosh import analysis, fields, reading
 from whoosh.compat import u, xrange

File tests/test_searching.py

 from __future__ import with_statement
 
-from nose.tools import assert_equal, assert_raises
+from nose.tools import assert_equal, assert_raises  #@UnresolvedImport
 
 from datetime import datetime, timedelta
 
     
     with ix.searcher() as s:
         q = Phrase("text", ["alfa", "bravo"])
-        r = s.search(q)
+        _ = s.search(q)
 
 def test_missing_field_scoring():
     schema = fields.Schema(name=fields.TEXT(stored=True),
                 Not(Term("text", "charlie"))])
         
         col = searching.TermTrackingCollector()
-        r = col.search(s, q)
+        _ = col.search(s, q)
         
         for docnum in col.catalog["text:alfa"]:
             words = s.stored_fields(docnum)["text"].split()

File tests/test_spans.py

 
 from nose.tools import assert_equal  #@UnresolvedImport
 
-from whoosh import analysis, fields, formats, query, spans
+from whoosh import analysis, fields, formats, spans
 from whoosh.compat import u, xrange
 from whoosh.filedb.filestore import RamStorage
-from whoosh.query import And, Or, Term
+from whoosh.query import And, Or, Term, Phrase
 from whoosh.util import permutations
 
 
 def test_regular_or():
     ix = get_index()
     with ix.searcher() as s:
-        oq = query.Or([query.Term("text", "bravo"), query.Term("text", "alfa")])
+        oq = Or([Term("text", "bravo"), Term("text", "alfa")])
         m = oq.matcher(s)
         while m.is_active():
             orig = s.stored_fields(m.id())["text"]
 def test_regular_and():
     ix = get_index()
     with ix.searcher() as s:
-        aq = query.And([query.Term("text", "bravo"), query.Term("text", "alfa")])
+        aq = And([Term("text", "bravo"), Term("text", "alfa")])
         m = aq.matcher(s)
         while m.is_active():
             orig = s.stored_fields(m.id())["text"]
 def test_span_characters():
     ix = get_index()
     with ix.searcher() as s:
-        pq = query.Phrase("text", ["bravo", "echo"])
+        pq = Phrase("text", ["bravo", "echo"])
         m = pq.matcher(s)
         while m.is_active():
             orig = " ".join(s.stored_fields(m.id())["text"])

File tests/test_tables.py

 from __future__ import with_statement
 import random
 
-from nose.tools import assert_equal
+from nose.tools import assert_equal  #@UnresolvedImport
 
 from whoosh.compat import u, b, xrange, iteritems, unichr
 from whoosh.filedb.filestore import RamStorage

File tests/test_vectors.py

 from __future__ import with_statement
 
-from nose.tools import assert_equal
+from nose.tools import assert_equal  #@UnresolvedImport
 
-from whoosh import analysis, fields, formats
+from whoosh import fields, formats
 from whoosh.compat import u
 from whoosh.filedb.filestore import RamStorage
 from whoosh.support.testing import TempIndex

File tests/test_weightings.py

 
 from nose.tools import assert_equal  #@UnresolvedImport
 
-from whoosh import query, scoring
+from whoosh import fields, query, scoring
 from whoosh.compat import u, xrange
-from whoosh.fields import *
 from whoosh.filedb.filestore import RamStorage
 from whoosh.util import permutations
 
 
 def _weighting_classes(ignore):
     # Get all the subclasses of Weighting in whoosh.scoring
-    return [c for name, c in inspect.getmembers(scoring, inspect.isclass)
+    return [c for _, c in inspect.getmembers(scoring, inspect.isclass)
             if scoring.Weighting in c.__bases__ and c not in ignore]
     
 def test_all():
     domain = [u("alfa"), u("bravo"), u("charlie"), u("delta"), u("echo"), u("foxtrot")]
-    schema = Schema(text=TEXT)
+    schema = fields.Schema(text=fields.TEXT)
     storage = RamStorage()
     ix = storage.create_index(schema)
     w = ix.writer()
         def final(self, searcher, docnum, score):
             return score * 1.5
     
-    schema = Schema(text=TEXT)
+    schema = fields.Schema(text=fields.TEXT)
     ix = RamStorage().create_index(schema)
     w = ix.writer()
     domain = "alfa bravo charlie delta".split()