Python Forum
Assert failure - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Assert failure (/thread-34818.html)



Assert failure - jtcostel - Sep-03-2021

We are supposed to write file out.

This is what I have and I am still getting an assertion failure:
with open('employee_salaries.tsv', 'w') as f_out:
  template = '{name},\t{salary}'
  for row in employee_table:
      sentence = template.format(name = row[0], salary = row[3])
      print(sentence)
      f_out.write(sentence +'\n')
Here is the assert test:
Error:
assert open('employee_salaries.tsv').read() == 'NAME\tEMPLOYEE ANNUAL SALARY\nBATEMAN, KELLY ANNE\t$118404.00\nCREMINS, KEVIN M\t$77238.00\nDAVIS, CRAIG W\t$77238.00\nMORENO, JOSE\t$120228.00\nURSETTA, ROSARIO\t$51216.00'



RE: Assert failure - buran - Sep-03-2021

We don't know what employee_table is and what data there are in it. Do you have the header in it? Also the expected output does not have comma (like your template) just tab. show what your generated file looks like.