From 8cb676f9d419946b61a7aaea5b76b1d8415e8a7f Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Sat, 26 Feb 2022 17:19:18 +0800 Subject: [PATCH] Enable test_word2vec_stand_alone_script by using sys.executable for python --- gensim/test/test_word2vec.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gensim/test/test_word2vec.py b/gensim/test/test_word2vec.py index 71996ca981..ce0b0ae389 100644 --- a/gensim/test/test_word2vec.py +++ b/gensim/test/test_word2vec.py @@ -14,6 +14,7 @@ import bz2 import sys import tempfile +import subprocess import numpy as np @@ -1162,15 +1163,15 @@ def test_path_line_sentences_one_file(self): # endclass TestWord2VecSentenceIterators -# TODO: get correct path to Python binary -# class TestWord2VecScripts(unittest.TestCase): -# def test_word2vec_stand_alone_script(self): -# """Does Word2Vec script launch standalone?""" -# cmd = 'python -m gensim.scripts.word2vec_standalone -train ' + datapath('testcorpus.txt') + \ -# ' -output vec.txt -size 200 -sample 1e-4 -binary 0 -iter 3 -min_count 1' -# output = check_output(cmd, stderr=PIPE) -# self.assertEqual(output, '0') -# #endclass TestWord2VecScripts +class TestWord2VecScripts(unittest.TestCase): + def test_word2vec_stand_alone_script(self): + """Does Word2Vec script launch standalone?""" + cmd = [sys.executable, '-m', 'gensim.scripts.word2vec_standalone', '-train', datapath('testcorpus.txt')] + \ + '-output vec.txt -size 200 -sample 1e-4 -binary 0 -iter 3 -min_count 1'.split() + output = check_output(args=cmd, stderr=subprocess.PIPE) + self.assertEqual(output, '0') + +#endclass TestWord2VecScripts if not hasattr(TestWord2VecModel, 'assertLess'):