Running tests failed

Question:

Good morning,
I am a beginner and learning python with free training from the openclassroom site. I have to do an exercise that I have completed, but when I try to validate the tests an error message appears in the console. I don’t understand the mistake I made, can you help me please.

Sincerely,
Repl link/Link to where the bug appears:
https://replit.com/@PythonBasics2-5/Regroupez-des-taches-en-utilisant-des-foncti-univergaminclub
Screenshots, links, or other helpful context:

def salaire_mensuel(salaire_annuel):
  salaire_mensuel = int(salaire_annuel) / 12
  return salaire_mensuel


def salaire_hebdomadaire(salaire_mensuel):
  salaire_hebdomadaire = salaire_mensuel / 4
  return salaire_hebdomadaire


def salaire_horaire(salaire_hebdomadaire, heures_travaillees):
  salaire_horaire = salaire_hebdomadaire / int(heures_travaillees)
  return salaire_horaire


def calcul(salaire_annuel, heures_travaillees):
  calcul = salaire_mensuel(salaire_annuel)
  calcul = salaire_hebdomadaire(calcul)
  calcul = salaire_horaire(calcul, heures_travaillees)
  return calcul


salaire_annuel = input("Entrez votre salaire annuel : ")
heures_travaillees = input(
  "Entrez le nombre d'heures travaillées par semaine : ")

resultat = calcul(salaire_annuel, heures_travaillees)
print(f"Votre salaire horaire est de {resultat} euros")

Hello @univergaminclub!
Can you try running kill 1 in the shell!

Hello,

Like this ?
image

Same error :
Installing imported packages
Running tests failed

Traceback (most recent call last):
  File "/home/runner/Regroupez-des-taches-en-utilisant-des-foncti-univergaminclub/_test_runnertest_runner.py", line 2, in <module>
    import _test_runnertest_suite
  File "/home/runner/Regroupez-des-taches-en-utilisant-des-foncti-univergaminclub/_test_runnertest_suite.py", line 2, in <module>
    from main import *
  File "/home/runner/Regroupez-des-taches-en-utilisant-des-foncti-univergaminclub/main.py", line 23, in <module>
    salaire_annuel = input("Entrez votre salaire annuel : ")
RuntimeError: input(): lost sys.stdin

exit status 1

Could you try opening the shell, typing read and pressing Enter?

Sure !

I think you might want to change the tag to Bug Reports.

The OP’s code runs fine for me, I think it’s on his/her end.

1 Like

I have same problem :frowning:

My apologies I just realized you were using unit tests and not just a normal run, could you also provide a screenshot or the code for your test?

The code for my unit tests is main.py, i send the code in screenshot and the code where u can copy/paste. Thank’s for your help !

Commenting out the last 4 lines like so should allow your tests to work properly

def salaire_mensuel(salaire_annuel):
  salaire_mensuel = int(salaire_annuel) / 12
  return salaire_mensuel


def salaire_hebdomadaire(salaire_mensuel):
  salaire_hebdomadaire = salaire_mensuel / 4
  return salaire_hebdomadaire


def salaire_horaire(salaire_hebdomadaire, heures_travaillees):
  salaire_horaire = salaire_hebdomadaire / int(heures_travaillees)
  return salaire_horaire


def calcul(salaire_annuel, heures_travaillees):
  calcul = salaire_mensuel(salaire_annuel)
  calcul = salaire_hebdomadaire(calcul)
  calcul = salaire_horaire(calcul, heures_travaillees)
  return calcul


#salaire_annuel = input("Entrez votre salaire annuel : ")
#heures_travaillees = input("Entrez le nombre d'heures travaillées par semaine : ")

#resultat = calcul(salaire_annuel, heures_travaillees)
#print(f"Votre salaire horaire est de {resultat} euros")

:robot:In general, inputs such as user inputs or external data are bad for unit testing because they can introduce variability and unpredictability into the test. Unit tests are supposed to be repeatable and independent of external factors, and using user inputs makes the test results dependent on the specific input given at the time of testing. This can make it difficult to reproduce and debug issues, and it also makes test results less reliable. Instead, unit tests should use predefined input values or mocked objects to ensure consistent and predictable test outcomes.

2 Likes

Thank’s a lot it works !

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.