import pytest

from balance_parens import *

string_to_balanced_parens_truth = {
    '': True,
    'hello world': True,
    '(': False,
    ')': False,
    '()': True,
    '((())': False,
    '((()))': True,
    '(a((b)))': True,
    '((())))': False,
    'hello(a(b())))world': False,
    '(a(b(c)d)e)': True,
}
@pytest.mark.parametrize('s, expected_parens_are_balanced', string_to_balanced_parens_truth.items())
def test_known_string_returns_expected(s, expected_parens_are_balanced):
    assert expected_parens_are_balanced == parens_are_balanced(s) 

bad_values_to_expected_error = {
    None: TypeError,
    -1: TypeError,
    0: TypeError,
    1: TypeError,
    1+1j: TypeError,
    3.1415926: TypeError,
}
@pytest.mark.parametrize('bad_value, expected_error', bad_values_to_expected_error.items())
def test_bad_value_returns_expected_error(bad_value, expected_error):
    # Rendundant tests show alternate syntax.

    with pytest.raises(expected_error):
        parens_are_balanced(bad_value)

    # older syntax works with 2.4
    pytest.raises(expected_error, "parens_are_balanced(bad_value)")
