Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable test_word2vec_stand_alone_script by using sys.executable for python #3299

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions gensim/test/test_word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import bz2
import sys
import tempfile
import subprocess

import numpy as np

Expand All @@ -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,
Expand Down Expand Up @@ -1168,15 +1170,18 @@ 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',
]
output = check_output(args=cmd, stderr=subprocess.PIPE)
self.assertEqual(output, b'')


if not hasattr(TestWord2VecModel, 'assertLess'):
Expand Down