示例#1
0
    def test_write(self):
        write_rmb(self.file_path, range(10))

        money_list = []
        with open(self.file_path) as f:
            money_list = [i.strip() for i in f.readlines()]

        self.assertEqual(money_list, [str(i) for i in range(10)])
示例#2
0
    def test_write_big_file(self):
        max_rmb = 12345
        fake_open = mock_open()
        fake_path = '/it/is/a/fake/path'

        with patch('__builtin__.open', fake_open):
            write_rmb(fake_path, range(max_rmb))

        fake_open.assert_called_once_with(fake_path, 'w')
        fake_open().write.assert_called_once_with(
            os.linesep.join([str(i) for i in range(max_rmb)])
        )