Files and random numbers.

Re: Files and random numbers.

por Richard Lobb -
Número de respuestas: 2
There has to be some form of limit on the output that's displayed in a cell of the result table. Too much output would flood the browser and and waste space in the database (since all output is recorded there for every run). Simply truncating the output can lose you important output at the end of the run, such as an exception being thrown. So I chose to snip the middle out of the output and mark it as '<...snip...>'. I also limit line lengths and the number of lines.

If you really want to do your own thing you can write a combinator template grader, which can generate whatever output it likes, although there is fundamentally a limit on the amount of output a run can generate, enforced by Jobe.

I suggest trying to find a way to pose a question in such a way that a correct solution doesn't generate screeds of output. What is the learning outcome of the question you're asking the student? Does it really need megabytes of output to verify that the learning outcome has been achieved?
En respuesta a Richard Lobb

Re: Files and random numbers.

por Albert Levi -
So what triggers to snip the output? I could not find information about this. If I know it, I can avoid having snip in the expected output.
En respuesta a Albert Levi

Re: Files and random numbers.

por Mike McDowell -
You could capture the output into a list then assess it with your test (this works per test in the test code), limiting the printed output:

# Capture stdout
import sys, io
old_stdout = sys.stdout
new_stdout = io.StringIO()
sys.stdout = new_stdout

# Now run the student methods/code while output is off

# Restore stdout when you're ready to allow output again
sys.stdout = old_stdout
output = new_stdout.getvalue()

# Split captured output into lines for analysis
lines = output.splitlines()

# Output the results or feedback from your examination of lines/output for your test