Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

ForbiddenError after submitting the homework

GabrielAlexandru (7760 points)
2 4 29
in HW1 optional by (7.8k points)

Hey, I submitted the Homework earlier today. In my local machine every test passed.

In the virtual machine one test didn't pass though. I thought my program exceeded the maximum time, but after scrolling a couple of times in the "results" console I found this error:

args = ('py._io.terminalwriter', None, None, ['__doc__']), kargs = {}

name = 'py._io.terminalwriter' 

def _check_import(*args, **kargs)= 

name = args[0] 

if name in forbidden or (not forbidden and name not in allowed)= 

print(f"Importing {name} ({kargs}) (not allowed)") 

> raise ForbiddenError(f"The import of '{name}' is forbidden") 

E testlib.ForbiddenError= The import of 'py._io.terminalwriter' is forbidden 

testlib.py=42= ForbiddenError

I searched on this website and found that a similar error happened last year in the Italian course here.

So, I was wondering if it's a problem of my code or not.

P.S. I have yet to experiment how the forum works, so I apologise if the question's style isn't pretty.

308 views
closed

2 Answers

Best answer
gianluca5539 (9820 points)
4 6 44
by (9.8k points)
selected by

I think it's a timeout. As you can see in line 25 of the log you shared:

/usr/lib/python3/dist-packages/pytest_timeout.py=382= in write_title

 I downloaded the pytest_timeout library to check what was happening in line 382, and this is what I found out:

pytest.fail("Timeout >%ss" % timeout)

Maybe you have a very powerful machine that runs that code fast enough to pass the test, I don't know, but from what I can see it looks like a timeout error. 

GabrielAlexandru (7760 points)
2 4 29
by (7.8k points)
So, now another question arise: why it is shown as ForbiddenError instead of TimeoutError? I know though there's  nothing we can do as the execution happens on a virtual machine we can't access.

Hopefully someone can confirm that the error it's actually a timeout. Thank you for your time!
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
I think the pytest machinery tries to import a module when showing the timeout error and this is what caught your eye.

I will have a look at simplifying the output or the tests to avoid such additional error message
gianluca5539 (9820 points)
4 6 44
by (9.8k points)

Did you import any libraries that you then forgot to remove? Like to track time for example.

Note that no libraries are allowed for this exercise. 

raise ForbiddenError(f"The import of '{name}' is forbidden")

GabrielAlexandru (7760 points)
2 4 29
by (7.8k points)
I didn't import any library. Every other test worked fine.

The error was raised only in one test.
gianluca5539 (9820 points)
4 6 44
by (9.8k points)
I think there is an error, it looks like pytest is trying to use terminalwriter to display the error message. Can you paste the full logs of the pytest in a pastebin or something? Thank you
GabrielAlexandru (7760 points)
2 4 29
by (7.8k points)

Here is the failure log.

gianluca5539 (9820 points)
4 6 44
by (9.8k points)
I think I know what happened, I will post another answer.