def setUp(self): self.txt_handler = TXTHandler() self.txt_file = TXTHandler() # get the pathdir where the application is running file = sys.argv[0] self.pathname = os.path.dirname(file) # create an file to test the existing file case my_file = open(self.pathname + '/test_exist_file.txt', 'w') my_file.write("te") my_file.close() # Valid txt format 9x9 self.txt = open('valid_sudoku_0.txt', 'rb') self.valid_txt = self.txt.read() # Invalid txt format 9x9 self.txt = open('invalid_sudoku_0.txt', 'rb') self.invalid_txt = self.txt.read() self.size = len(self.valid_txt)
def test_read_sudoku_for_invalid_txt_using_separator_dot(self): txt_file = TXTHandler() self.expected = '3.657..2\n' + \ '..913.76.\n' + \ '487...531\n' + \ '26..15.8.\n' + \ '...86..25\n' + \ '.5.7.2.4.\n' + \ '.389.725.\n' + \ '6.2..1.74\n' result = self.txt_file.get_sudoku_data('invalid_sudoku_dot.txt') self.assertEquals(self.expected, result[0][0])