Exemplo n.º 1
0
    def test_read_big_file(self):
        test_list = [str(i) for i in range(12345)]
        fake_open = mock_open(read_data=os.linesep.join(test_list))
        fake_path = '/it/is/a/fake/path'

        money_list = []
        with patch('__builtin__.open', fake_open):
            money_list = read_dollar(fake_path)

        self.assertEqual(money_list, test_list)
        fake_open.assert_called_once_with(fake_path)
Exemplo n.º 2
0
    def test_read(self):
        file_path = os.path.join(self.test_dir, 'money.txt')
        money_list = read_dollar(file_path)

        self.assertEqual(money_list, ['1', '2', '3', '4'])
        self.assertItemsEqual(money_list, ['4', '1', '2', '3'])