本文整理汇总了Python中convert.Convert.txt_file_to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.txt_file_to_string方法的具体用法?Python Convert.txt_file_to_string怎么用?Python Convert.txt_file_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类convert.Convert
的用法示例。
在下文中一共展示了Convert.txt_file_to_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestConvert
# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import txt_file_to_string [as 别名]
class TestConvert(unittest.TestCase):
def setUp(self):
self.convert = Convert()
self.validtxt = "juego.txt"
self.invalidtxt = "juego1.txt"
self.validcsv = "juego.csv"
self.invalidcsv = "juego1.csv"
### ******* Unittest for convert class *************
def test_if_txt_file_is_converted_to_string(self):
expected = type(self.validtxt)
self.assertEqual(expected,type(self.convert.txt_file_to_string(self.validtxt)))
def test_if_string_from_txt_file_is_correct_converted(self):
expected = '003020600900305001001806400008102900700000008006708200002609500800203009005010300'
self.assertEqual(expected,self.convert.txt_file_to_string(self.validtxt))
def test_if_txt_file_convert_display_a_friendly_message_for_invalid_input(self):
expected = "Please insert a txt file with the correct dimensions"
self.assertEqual(expected,self.convert.txt_file_to_string(self.invalidtxt))
def test_if_csv_file_is_converted_to_string(self):
expected = type(self.validcsv)
self.assertEqual(expected,type(self.convert.csv_file_to_string(self.validcsv)))
def test_if_string_from_csv_file_is_correct_converted(self):
expected = '003020600900305001001806400008102900700000008006708200002609500800203009005010300'
self.assertEqual(expected,self.convert.csv_file_to_string(self.validcsv))
def test_if_csv_file_convert_display_a_friendly_message_for_invalid_input(self):
expected = "Please insert a csv file with the correct dimensions"
self.assertEqual(expected,self.convert.csv_file_to_string(self.invalidcsv))