diff --git a/gensim/test/test_similarities.py b/gensim/test/test_similarities.py index 8179c25f78..091766816a 100644 --- a/gensim/test/test_similarities.py +++ b/gensim/test/test_similarities.py @@ -515,24 +515,25 @@ def assertApproxNeighborsMatchExact(self, model, wv, index): self.assertEqual(approx_words, exact_words) def assertIndexSaved(self, index): - index.save('index') - self.assertTrue(os.path.exists('index')) - self.assertTrue(os.path.exists('index.d')) + fname = testfile() + index.save(fname) + self.assertTrue(os.path.exists(fname)) + self.assertTrue(os.path.exists(fname + '.d')) def assertLoadedIndexEqual(self, index, model): from gensim.similarities.index import AnnoyIndexer - index.save('index') + fname = testfile() + index.save(fname) index2 = AnnoyIndexer() - index2.load('index') + index2.load(fname) index2.model = model self.assertEqual(index.index.f, index2.index.f) self.assertEqual(index.labels, index2.labels) self.assertEqual(index.num_trees, index2.num_trees) - class TestDoc2VecAnnoyIndexer(unittest.TestCase): def setUp(self): @@ -566,9 +567,10 @@ def testApproxNeighborsMatchExact(self): self.assertEqual(approx_words, exact_words) def testSave(self): - self.index.save('index') - self.assertTrue(os.path.exists('index')) - self.assertTrue(os.path.exists('index.d')) + fname = testfile() + self.index.save(fname) + self.assertTrue(os.path.exists(fname)) + self.assertTrue(os.path.exists(fname + '.d')) def testLoadNotExist(self): from gensim.similarities.index import AnnoyIndexer @@ -579,10 +581,11 @@ def testLoadNotExist(self): def testSaveLoad(self): from gensim.similarities.index import AnnoyIndexer - self.index.save('index') + fname = testfile() + self.index.save(fname) self.index2 = AnnoyIndexer() - self.index2.load('index') + self.index2.load(fname) self.index2.model = self.model self.assertEqual(self.index.index.f, self.index2.index.f)