Closed hugobowne closed 8 years ago
# Tests for the context manager body
def test_with_body():
# Test: call to con.execute() and 'rs' variable
test_object("rs", do_eval = False)
test_function("con.execute")
# Test: call to pd.DataFrame() and 'df' variable
test_correct(
lambda: test_object_after_expression("df"),
lambda: test_function("pandas.DataFrame", do_eval = False)
)
# Test: call to rs.keys() and df.columns
test_correct(
lambda: test_expression_result(expr_code = "df.columns"),
lambda: test_function("rs.keys")
)
# Test: Context manager
test_with(
1,
context_vals = True,
context_tests = lambda: test_function("engine.connect"),
body = test_with_body
)
# Test: Predefined code
predef_msg = "You don't have to change any of the predefined code."
test_function("print", index = 1, incorrect_msg = predef_msg)
test_function("print", index = 2, incorrect_msg = predef_msg)
success_msg("Awesome!")
https://campus.datacamp.com/courses/1167/2629?ex=8
it's weird because this error doesn't show up in any other SQL exercises.