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

Do you need help?

Problema test apertura program01

d
daniele.marretta (280 points)
1 2 3
in HW6 by (280 points)
Buonasera, tentando di testare il codice per l'homework 6, tutti i test mi hanno dato questo errore:

test_01.py:41: in do_test

import program01 as program
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('program01', {'@py_builtins': <module 'builtins' (built-in)>, '@pytest_ar': <module '_pytest.assertion.rewrite' from ...n3.8/site-packages/_pytest/assertion/rewrite.py'>, 'DEBUG': False, 'Test': <class 'test_01.Test'>, ...}, None, None, 0)
kargs = {}, name = 'program01'
rest = [{'@py_builtins': <module 'builtins' (built-in)>, '@pytest_ar': <module '_pytest.assertion.rewrite' from '/home/daniel...n3.8/site-packages/_pytest/assertion/rewrite.py'>, 'DEBUG': False, 'Test': <class 'test_01.Test'>, ...}, None, None, 0]

    def _check_import(*args, **kargs):
        name, *rest = args
        if name in forbidden or (not forbidden and name not in allowed):
            print(f"Importing {name} (globals, locals, {rest[-2:]}) (not allowed)")
            raise ForbiddenError(f"The import of '{name}' is forbidden")
        else:
>           return self.__orig_import(*args, **kargs)
              File "/home/daniele/Documents/PythonExercises/HW6-req/program01.py", line 1
                '''
                ^
             SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe0 in position 24: invalid continuation byte

Come se l'encoding del file program01 non fosse utf-8.  Ho modificato il file solo dentro spyder. Inoltre lo stesso problema non me lo dà se provo ad usare il file in inglese. (Specifico che sono su Linux)

Ovviamente basterebbe usare il file in inglese, però chiedo per capire se è un problema che dipende da me e capire dove sbaglio
350 views
closed

1 Answer

Best answer
Matypist (5370 points)
11 16 45
by (5.4k points)
selected by

Check list:

  • Hai rinominato il file 'program01.ita.py' in 'program01.py'?
  • Hai provato a cancellare tutti i commenti della consegna dal file (lasciare quindi solo il tuo codice), salvare e rieseguirlo?
d
daniele.marretta (280 points)
1 2 3
by (280 points)
Sì il file l'avevo rinominato. Provando a cancellare la consegna invece funziona. Anche se di solito negli altri homework l'ho sempre lasciata, strano. Comunque grazie mille
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)

Avete provato ad aggiungere la prima riga?

# -*- coding: utf-8 -*-

d
daniele.marretta (280 points)
1 2 3
by (280 points)
Ho provato ma non va comunque, forse è un bug del mio pc, non so. A quanto pare l'unica cosa è cancellare la consegna o usare il file in inglese