<commit_before>
__author__      = "<NAME>"
__copyright__   = "Copyright 2016, Xilinx"
__maintainer__  = "<NAME>"
__email__       = "<EMAIL>"


import pytest
import sys, select, termios
from pyxi.audio import LineIn, Headphone
from pyxi.test.util import user_answer_yes

flag = user_answer_yes("\nBoth LineIn and Headphone (HPH) jacks connected?")
    
@pytest.mark.run(order=34)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_LineIn():
    """ Tests whether the __call__() method correctly returns
        The returned value should be a list of two integers.
    """
    linein = LineIn()
    assert type(linein()) is list, 'returned value is not a list'
    assert len(linein())==2, 'returned list does not have 2 elements'
    assert type(linein()[0]) is int, '1st element in the list is not int'
    assert type(linein()[1]) is int, '2nd element in the list is not int'

@pytest.mark.run(order=35)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_audio_loop():
    """ Tests whether the two objects works properly using their __call__()
        methods, asking for user confirmation.
    """
    headphone = Headphone()
    linein = LineIn()
    print("\nMake sure LineIn is receiveing audio.")
    print("Hit enter to stop...", end="")
    while True:
        headphone(linein())
        if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
            termios.tcflush(sys.stdin, termios.TCIOFLUSH)
            break
    assert user_answer_yes("Heard audio on the headphone (HPH) port?"),\
        'audio loop is not working'

@pytest.mark.run(order=36)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_audio_mute():
    """ Tests is_muted() and toggle_mute() methods.
    """ <commit_msg>small fix for audio test<commit_after>
__author__      = "<NAME>"
__copyright__   = "Copyright 2016, Xilinx"
__maintainer__  = "<NAME>"
__email__       = "<EMAIL>"


import pytest
import sys, select, termios
from pyxi.audio import LineIn, Headphone
from pyxi.test.util import user_answer_yes

flag = user_answer_yes("\nBoth LineIn and Headphone (HPH) jacks connected?")
    
@pytest.mark.run(order=34)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_LineIn():
    """ Tests whether the __call__() method correctly returns
        The returned value should be a list of two integers.
    """
    linein = LineIn()
    assert type(linein()) is list, 'returned value is not a list'
    assert len(linein())==2, 'returned list does not have 2 elements'
    assert type(linein()[0]) is int, '1st element in the list is not int'
    assert type(linein()[1]) is int, '2nd element in the list is not int'

@pytest.mark.run(order=35)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_audio_loop():
    """ Tests whether the two objects works properly using their __call__()
        methods, asking for user confirmation.
    """
    headphone = Headphone()
    linein = LineIn()
    print("\nMake sure LineIn is receiveing audio. Hit enter to stop...", \
            end="")
    while True:
        headphone(linein())
        if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
            termios.tcflush(sys.stdin, termios.TCIOFLUSH)
            break
    assert user_answer_yes("Heard audio on the headphone (HPH) port?"),\
        'audio loop is not working'

@pytest.mark.run(order=36)
@pytest.mark.skipif(not flag, reason="need both LineIn and HPH attached")
def test_audio_mute():
    """ Tests is_muted() and toggle_mute() methods.
    """ 
{'fraction_non_alphanumeric': 0.12085176991150443, 'fraction_numerical': 0.00995575221238938, 'mean_word_length': 3.538268506900878, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2748946', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1146, 'n_words': 380}