Spaces:
Sleeping
Sleeping
epochs-demos
commited on
Commit
•
5173311
1
Parent(s):
35e9382
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -38,21 +38,22 @@ def check_solution(instructor_code, student_code, function_name, test_cases):
|
|
38 |
expected_result_list = []
|
39 |
actual_result_list = []
|
40 |
test_result = []
|
41 |
-
for
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
result_df = pd.DataFrame({
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
}, index=None)
|
51 |
st.markdown(result_df.style.hide(axis="index").to_html(), unsafe_allow_html=True)
|
52 |
st.markdown("<br>", unsafe_allow_html=True)
|
53 |
|
54 |
# Check if all tests passed
|
55 |
-
if
|
56 |
st.success("All tests passed!")
|
57 |
else:
|
58 |
st.error("Some tests failed.")
|
|
|
38 |
expected_result_list = []
|
39 |
actual_result_list = []
|
40 |
test_result = []
|
41 |
+
for test_case in test_cases:
|
42 |
+
expected_result = instructor_function(*test_case)
|
43 |
+
actual_result = student_function(*test_case)
|
44 |
+
expected_result_list.append(expected_result)
|
45 |
+
actual_result_list.append(actual_result)
|
46 |
+
test_result.append("Passed" if expected_result == actual_result else "Failed")
|
47 |
result_df = pd.DataFrame({
|
48 |
+
"Expected": expected_result_list,
|
49 |
+
"Run": actual_result_list,
|
50 |
+
"Result": test_result
|
51 |
}, index=None)
|
52 |
st.markdown(result_df.style.hide(axis="index").to_html(), unsafe_allow_html=True)
|
53 |
st.markdown("<br>", unsafe_allow_html=True)
|
54 |
|
55 |
# Check if all tests passed
|
56 |
+
if all(expected == actual for expected, actual in zip(expected_result_list, actual_result_list)):
|
57 |
st.success("All tests passed!")
|
58 |
else:
|
59 |
st.error("Some tests failed.")
|