Skip to content

Commit 59f8a84

Browse files
committed
Fix test on windows due to differing explain text
1 parent c466eb1 commit 59f8a84

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ropetest/contrib/autoimport/autoimporttest.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,36 @@ def test_setup_db_metadata_table_is_current(autoimport):
189189

190190

191191
class TestQueryUsesIndexes:
192+
def explain(self, autoimport, query):
193+
explanation = list(autoimport._execute(query.explain(), ("abc",)))[0][-1]
194+
# the explanation text varies, on some sqlite version
195+
explanation = explanation.replace("TABLE ", "")
196+
return explanation
197+
192198
def test_search_by_name_uses_index(self, autoimport):
193-
query = models.Name.search_by_name.select_star().explain()
199+
query = models.Name.search_by_name.select_star()
194200
assert (
195-
list(autoimport._execute(query, ("abc",)))[0][-1]
201+
self.explain(autoimport, query)
196202
== "SEARCH names USING INDEX names_name (name=?)"
197203
)
198204

199205
def test_search_by_name_like_uses_index(self, autoimport):
200-
query = models.Name.search_by_name_like.select_star().explain()
206+
query = models.Name.search_by_name_like.select_star()
201207
assert (
202-
list(autoimport._execute(query, ("abc",)))[0][-1]
208+
self.explain(autoimport, query)
203209
== "SEARCH names USING INDEX names_name_nocase (name>? AND name<?)"
204210
)
205211

206212
def test_search_module_like_uses_index(self, autoimport):
207-
query = models.Name.search_module_like.select_star().explain()
213+
query = models.Name.search_module_like.select_star()
208214
assert (
209-
list(autoimport._execute(query, ("abc",)))[0][-1]
215+
self.explain(autoimport, query)
210216
== "SEARCH names USING INDEX names_module_nocase (module>? AND module<?)"
211217
)
212218

213219
def test_search_submodule_like_uses_index(self, autoimport):
214-
query = models.Name.search_submodule_like.select_star().explain()
220+
query = models.Name.search_submodule_like.select_star()
215221
assert (
216-
list(autoimport._execute(query, ("abc",)))[0][-1]
222+
self.explain(autoimport, query)
217223
== "SCAN names" # FIXME: avoid full table scan
218224
)

0 commit comments

Comments
 (0)