Ejemplo n.º 1
0
 def test_deep_copy_happens(self):
     original = [1, 2, [3, 4]]
     loaded = tsm.load_data(original)
     # Test copy is effective:
     self.assertEqual(original, loaded)
     # Test copy is not by reference:
     self.assertIsNot(original, loaded)
     # Test copy is deep:
     self.assertIsNot(original[2], loaded[2])
Ejemplo n.º 2
0
 def test_deep_copy_happens(self):
     original = [1, 2, [3, 4]]
     loaded = tsm.load_data(original)
     # Test copy is effective:
     self.assertEqual(original, loaded)
     # Test copy is not by reference:
     self.assertIsNot(original, loaded)
     # Test copy is deep:
     self.assertIsNot(original[2], loaded[2])
Ejemplo n.º 3
0
 def test_strips_empty_lines_from_csv(self):
     fake_file = io.StringIO('\0one,t\0wo,three\n\n1\0,2,3\n\0')
     with mock.patch('builtins.open', return_value=fake_file):
         result = tsm.load_data('path')
     self.assertEqual(result, [['one', 'two', 'three'], ['1', '2', '3']])
Ejemplo n.º 4
0
 def test_returns_list_of_lists_from_csv(self):
     fake_file = io.StringIO('one,two,three\n1,2,3\n')
     with mock.patch('builtins.open', return_value=fake_file):
         result = tsm.load_data('path')
     self.assertEqual(result, [['one', 'two', 'three'], ['1', '2', '3']])
Ejemplo n.º 5
0
 def test_calls_open_with_encoding(self, mock_open):
     result = tsm.load_data('path', enc='other')
     mock_open.assert_called_once_with('path', 'r', encoding='other',
                                       errors='replace')
Ejemplo n.º 6
0
 def test_calls_open_with_default_args(self, mock_open):
     result = tsm.load_data('path')
     mock_open.assert_called_once_with('path', 'r',
                                       encoding='utf-8', errors='replace')
Ejemplo n.º 7
0
 def test_strips_empty_lines_from_csv(self):
     fake_file = io.StringIO('\0one,t\0wo,three\n\n1\0,2,3\n\0')
     with mock.patch('builtins.open', return_value=fake_file):
         result = tsm.load_data('path')
     self.assertEqual(result, [['one', 'two', 'three'], ['1', '2', '3']])
Ejemplo n.º 8
0
 def test_returns_list_of_lists_from_csv(self):
     fake_file = io.StringIO('one,two,three\n1,2,3\n')
     with mock.patch('builtins.open', return_value=fake_file):
         result = tsm.load_data('path')
     self.assertEqual(result, [['one', 'two', 'three'], ['1', '2', '3']])
Ejemplo n.º 9
0
 def test_calls_open_with_encoding(self, mock_open):
     result = tsm.load_data('path', enc='other')
     mock_open.assert_called_once_with('path',
                                       'r',
                                       encoding='other',
                                       errors='replace')
Ejemplo n.º 10
0
 def test_calls_open_with_default_args(self, mock_open):
     result = tsm.load_data('path')
     mock_open.assert_called_once_with('path',
                                       'r',
                                       encoding='utf-8',
                                       errors='replace')