<commit_before>import re
import pytest
from py_word_suggest.Selector import *

@pytest.fixture()
def bigrams():
    b = {'I':[['am',1],['want', 10], ['like', 5]]}
    bigrams = Selector(b)
    return bigrams

@pytest.mark.skip
def test_getsuggestedwords(bigrams):
    """Selector: Get all suggested words of words 'I'
    :returns: TODO
    """
    match = ('want', 'like', 'am')
    # assertListEqual(list(bigram.gen_suggestWord(*x)), match, "Should be ['want', 'like','am']")
    result = set(bigrams.get_suggestWord('I',True))
#    assert obj.p() == "t"
    assert match == result

<EMAIL>
def test_genSuggestedWords(bigrams):
    """Selector: Generate suggested words object"""
    #Test set
    assert bigrams._suggestWords == None
    smatch = {'want', 'like', 'am'}
    bigrams.set_suggestedWords('I')
   #test empty after list
    assert set(bigrams._suggestWords) == smatch
    assert bigrams._suggestWords == None
    usmatch = {'am','like','want'}
    bigrams.set_suggestedWords('I',sort=False)
    assert set(bigrams._suggestWords) == usmatch
    assert bigrams._suggestWords == None
    #Test list
    lmatch = ['want', 'like', 'am']
    bigrams.set_suggestedWords('I',sort=True)
    assert list(bigrams._suggestWords) == lmatch
    assert bigrams._suggestWords == None
    ulmatch = ['am','like','want']
    bigrams.set_suggestedWords('I',sort=False)
    assert list(bigrams._suggestWords) == ulmatch
    assert bigrams._suggestWords == None

@pytest.mark.skip
def test_getSuggestedWords(bigrams):
    """Selector: Generate suggested words object"""
    assert bigrams.selectedSuggestWords == None
    match = {'want', 'like', 'am'}
    bigrams.set_suggestedWords('I')
    assert bigrams._suggestWords == match

@pytest.mark.parametrize("testInput,sortTypeOutput",
            [
            (None,['am','want','like']),
            (True,['want','like','am']),
            (False,['am','like','want'])
            ]
        )
def test_setSuggestedWords(bigrams, testInput, sortTypeOutput):
    """Selector: Set list of suggested word to object"""
    bigrams.set_suggestedWords('I',sort=testInput)
    assert list(bigrams._suggestWords) == sortTypeOutput
    assert bigrams._suggestWords == None

def test_setSelectedBigram(bigrams):
    """Selector: Set Suggested bigram (values of basekey) to object"""
    assert bigrams._selectedBigram == None
    bigramValues = [['am',1],['want', 10], ['like', 5]]   
    bigrams.set_bigram('I')
    assert bigrams._selectedBigram == bigramValues
    with pytest.raises(SelectorNoBaseKeyFoundError) as e:<commit_msg>[json_support] Optimize test test_gensuggestedwords()<commit_after>import re
import pytest
from py_word_suggest.Selector import *

@pytest.fixture()
def bigrams():
    b = {'I':[['am',1],['want', 10], ['like', 5]]}
    bigrams = Selector(b)
    return bigrams

@pytest.mark.skip
def test_getsuggestedwords(bigrams):
    """Selector: Get all suggested words of words 'I'
    :returns: TODO
    """
    match = ('want', 'like', 'am')
    # assertListEqual(list(bigram.gen_suggestWord(*x)), match, "Should be ['want', 'like','am']")
    result = set(bigrams.get_suggestWord('I',True))
#    assert obj.p() == "t"
    assert match == result

@pytest.mark.parametrize("testInput,sortTypeOutput",
            [
            (None,['am','want','like']),
            (True,['want','like','am']),
            (False,['am','like','want'])
            ]
        )
#@pytest.mark.skip
def test_genSuggestedWords(bigrams, testInput, sortTypeOutput):
    """Selector: Generate suggested words object"""
    gen = bigrams.gen_suggestWord('I',sort=testInput)
    for testValue, generatedValue in zip(gen, sortTypeOutput):
        assert testValue == generatedValue

@pytest.mark.skip
def test_getSuggestedWords(bigrams):
    """Selector: Generate suggested words object"""
    assert bigrams.selectedSuggestWords == None
    match = {'want', 'like', 'am'}
    bigrams.set_suggestedWords('I')
    assert bigrams._suggestWords == match

@pytest.mark.parametrize("testInput,sortTypeOutput",
            [
            (None,['am','want','like']),
            (True,['want','like','am']),
            (False,['am','like','want'])
            ]
        )
def test_setSuggestedWords(bigrams, testInput, sortTypeOutput):
    """Selector: Set list of suggested word to object"""
    bigrams.set_suggestedWords('I',sort=testInput)
    assert list(bigrams._suggestWords) == sortTypeOutput
    assert bigrams._suggestWords == None

def test_setSelectedBigram(bigrams):
    """Selector: Set Suggested bigram (values of basekey) to object"""
    assert bigrams._selectedBigram == None
    bigramValues = [['am',1],['want', 10], ['like', 5]]   
    bigrams.set_bigram('I')
    assert bigrams._selectedBigram == bigramValues
    with pytest.raises(SelectorNoBaseKeyFoundError) as e:
{'fraction_non_alphanumeric': 0.1555232558139535, 'fraction_numerical': 0.0033222591362126247, 'mean_word_length': 3.9405128205128204, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7283606', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1513, 'n_words': 324}