Avviando il test_01.py mi da questo errore e mi blocca tutto. Come posso risolvere?

S
SimyKek (340 points)
4 8 9
asked Oct 28, 2021 in HW2 by SimyKek (340 points)
recategorized Oct 28, 2021 by SimyKek
test_emoji_10_10_50_00001_test_emoji_10_10_50 (__main__.Test)
test_emoji_10_10_50_00001_test_emoji_10_10_50 ...
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 457, in _handle_events
    self._rebuild_io_state()
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 512, in _rebuild_io_state
    self._update_handler(state)
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 529, in _update_handler
    if state & self.socket.events:
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\sugar\attrsettr.py", line 48, in __getattr__
    from zmq import ZMQError
  File "C:\Users\utente\Roba di Python\HW2-req\testlib.py", line 44, in _check_import
    raise ForbiddenError(f"The import of '{name}' is forbidden")
testlib.ForbiddenError: The import of 'zmq' is forbidden
ERROR:tornado.application:Exception in callback functools.partial(<function ZMQStream._update_handler.<locals>.<lambda> at 0x000002A321036EE0>)
Traceback (most recent call last):
  File "C:\Users\utente\anaconda3\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
    ret = callback()
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 532, in <lambda>
    self.io_loop.add_callback(lambda: self._handle_events(self.socket, 0))
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 457, in _handle_events
    self._rebuild_io_state()
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 512, in _rebuild_io_state
    self._update_handler(state)
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 529, in _update_handler
    if state & self.socket.events:
  File "C:\Users\utente\anaconda3\lib\site-packages\zmq\sugar\attrsettr.py", line 48, in __getattr__
    from zmq import ZMQError
  File "C:\Users\utente\Roba di Python\HW2-req\testlib.py", line 44, in _check_import
    raise ForbiddenError(f"The import of '{name}' is forbidden")
testlib.ForbiddenError: The import of 'zmq' is forbidden

Il codice prosegue all'infinito.

Ho provato a bloccare, ma non mi fa più interagire con la console di Spyder.

Ho riavviato la Kernel, ma mi da questo errore se decido di riavviare il test:

Reloaded modules: testlib, program01
This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was:

An exception has occurred, use %tb to see the full traceback.

UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2169: character maps to <undefined>

Il codice è vuoto, ho aggiunto solamente pass, nient'altro. Come posso risolvere?
208 views

1 Answer

Best answer
Exyss (21390 points)
1 2 79
answered Oct 28, 2021 by Exyss (21,390 points)
selected Oct 28, 2021 by SimyKek

Come hanno consigliato già in questo thread, prova ad eliminare  la riga

self.check_imports(allowed=['program01','_io']), \

nel file test_01.py alla funzione do_test(), dovrebbe risolvere il problema

Matypist (5370 points)
8 16 45
commented Oct 28, 2021 by Matypist (5,370 points)
Altrimenti penso si possa risolvere anche rinominando "program01.eng.py" o "program01.ita.py" in "program01.py", che è il nome del file che si aspetta il codice python dei tests
anaran (7090 points)
2 5 37
commented Oct 28, 2021 by anaran (7,090 points)
Si, credo anche che bisognerebbe rinominarlo e consegnarlo come program01.py,