appunittest.py 776 B

1234567891011121314151617181920212223242526272829
  1. # File Name: appunittest.py
  2. # Date: March 3, 2017
  3. # Description: This class is for testing write file and read file in app.py
  4. __author__ = "Inyoung Choung"
  5. import os
  6. from os import path
  7. import unittest
  8. import app
  9. # testing file IO
  10. class writefiletest(unittest.TestCase):
  11. def runTest(self):
  12. # set path
  13. filepath = "C:\In-young Choung\Computer Programming\Self Programming Files\grocerycalc\pytest.txt"
  14. # create a file and write "pythontest"
  15. app.writefile(filepath, "pythontest")
  16. # read the file that is just created
  17. app.readfile(filepath)
  18. # check if the file is correctly created in the path
  19. self.assertTrue(str(path.isfile("pytest.txt")))
  20. # class starter
  21. if __name__ == '__main__':
  22. unittest.main()