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

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

error : The import of 'collections.abc' is forbidden

matteo_b (950 points)
14 27 33
in HW5 optional by (950 points)

By testing my solutioin to the homework5 five I get this error, but I don't understand why, as I imported only the images module.

FAILED test_01.py::Test::test_data_01___1___1080_ - testlib.ForbiddenError: The import of 'collections.abc' is forbidden
...

What does that module do? What is it for?

115 views

2 Answers

AL1990 (28120 points)
3 6 142
by (28.1k points)
Does it give you the error both locally and on the VM? I think it's a library loaded by tests to report an error. Try running the function directly and see if it gives you an error.
aryanahamed (7920 points)
6 12 67
by (7.9k points)

I am pretty much sure that, the issue is with the testfiles/png module/images module. I ran the tests in an empty file with only the images module imported and it threw the same error you mentioned. But the error was gone when I removed the import images.

One way to fix this is to edit test01.py and adding 'collections.abc' in self.check_imports() [Line 31] along with other allowed imports. But I wouldn't really suggest you to edit the test files.