diff --git a/gensim/test/test_word2vec.py b/gensim/test/test_word2vec.py index 71996ca981..c27621f04d 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 @@ -27,6 +28,7 @@ from gensim import utils from gensim.models import word2vec, keyedvectors +from gensim.utils import check_output from gensim.test.utils import ( datapath, get_tmpfile, temporary_file, common_texts as sentences, LeeCorpus, lee_corpus_list, @@ -1162,15 +1164,17 @@ 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'):