def test_random_name(): p = random_name(gender='female', region='canada') assert len(p) > 3 assert ', ' in p with pytest.raises(ValueError) as excinfo: random_name(gender='fjweiuw', region='canada') assert "{'error': 'Invalid gender'}" in str(excinfo.value)
def test_random_name(): p = random_name(gender='female', region='canada') assert (len(p) > 3) assert (', ' in p) with pytest.raises(ValueError) as excinfo: random_name(gender='fjweiuw', region='canada') assert '{"error":"Invalid gender"}' in str(excinfo.value)
def test_random_name(): p = random_name(gender='female', region='canada') assert isinstance(p, str) assert len(p) > 3 assert ', ' in p with pytest.raises(ValueError) as excinfo: random_name(gender='fjweiuw', region='canada') assert re.match(r'{"error":\s*"Invalid gender"}', str(excinfo.value))