python - A question about a doctest-similar thing in the hog project of UCB CS61A - Stack Overflow

admin2025-04-20  0

I am working on the hog project from UCB CS61A. Your can find the info about this project here.

In this project, one is required to write a roll_dice(num_rolls,dice) function and then test it using their autograder. Info about the autograder can be found here.

I checked the test scripts and find something like

>>> roll_dice(2, make_test_dice(4, 6, 1))
8a27d52d885dfcd62a4a92cbfe64d30a

For anyone who want to check this, you can download hog.zip from the above link. Unzip the file into folder hog, then you can find the above script in \hog\tests\01.py

This looks super like a doctest. However, if I do treat it like a doctest and run

import doctest
doctest.testmod()

It failed obviously as the expected answer is 10 rather than the mysterious 8a27d52d885dfcd62a4a92cbfe64d30a. But it works if I run the test with their autograder.

I am just super curious about what is going on. Is that a mysterious way to encrypt? I am relatively new to CS, so please bear with me if this is an uninteresting question.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745110391a285546.html

最新回复(0)