def test_sort_1(self): with patch('student_management_system.open', self.m_open1): sms = StudentManagementSystem() sms.read('score.csv') result = sms.sort(order_key="register", order_way="asc") self.assertEqual('1,강호민,85,90,95,270,90', result)
def test_sort_5(self): with patch('student_management_system.open', self.m_open2): sms = StudentManagementSystem() sms.read('score.csv') result = sms.sort("stotal", "des") self.assertEqual('1,강호민,85,90,95,270,90\n2,김광호,80,70,60,210,70', result)
def test_sort_3(self): with patch('student_management_system.open', self.m_open2): sms = StudentManagementSystem() sms.read('score.csv') result = sms.sort(order_key="register", order_way="des") self.assertEqual('2,김광호,80,70,60,210,70\n1,강호민,85,90,95,270,90', result)
def test_write_2(self): with patch('student_management_system.open', self.m_write_open_1): sms = StudentManagementSystem() sms.read('score.csv') sms.write('result.csv', 'register', 'des') self.m_w.write.assert_called_with( "3,김민식,75,85,80,240,80\n2,김광호,80,70,60,210,70\n1,강호민,85,90,95,270,90" )
def test_read_2(self): with patch('student_management_system.open', self.m_open2): sms = StudentManagementSystem() self.assertEqual(2, sms.read('score.csv')) self.m_open2.assert_called_with('score.csv', 'rt', encoding="utf-8")
from student_management_system import StudentManagementSystem if __name__ == "__main__": sms = StudentManagementSystem() sms.read('score.csv') sms.write('pre_result.csv', "stotal", "des") sms2 = StudentManagementSystem() sms2.read_2('pre_result.csv') print(sms2.sort_2("stotal", "des")) sms2.write_2('result.csv', "stotal", "des")