Python Forum

Full Version: Assert failure
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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'
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.