def test_free_function_int(): val = m.frobnicate(5) assert val == 37 try: assert isinstance(val, (int, long)) except NameError: # Python 3 does not have 'long' assert isinstance(val, int)
def test_free_function_float(): val = m.frobnicate(5.0) assert val == 37.0 assert isinstance(val, float)
def test_free_function_invalid(): with pytest.raises(TypeError, match="incompatible function arguments"): m.frobnicate("uiae")
def test_free_function_invalid(): with pytest.raises(TypeError) as excinfo: m.frobnicate("uiae") assert "incompatible function arguments" in str(excinfo.value)