Пример #1
0
 def test_with_empty_file(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data=''))\
             as mock_open:
         with self.assertRaises(ValueError) as exc:
             get_format("./non-existant")
         self.assertIn("Empty file", str(exc.exception))
Пример #2
0
 def test_with_single_column(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data='heder\n1\n2\n3\n4')) \
             as mock_open:
         self.assertEqual(get_format("./non-existant"), "column-based")
Пример #3
0
 def test_with_wrong_quote(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data='"head, torso,1,2,3,4\ner,2,3,4,5'))\
             as mock_open:
         with self.assertRaises(ValueError):
             self.assertEqual(get_format("./non-existant"), "row-based")
Пример #4
0
 def test_with_quoted_comma(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data='"head, torso",1,2,3,4\ner,2,3,4,5'))\
             as mock_open:
         self.assertEqual(get_format("./non-existant"), "row-based")
Пример #5
0
 def test_with_row_based_file(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data='hed,1,2,3,4\ner,2,3,4,5')) \
             as mock_open:
         self.assertEqual(get_format("./non-existant"), "row-based")
Пример #6
0
 def test_with_col_based_file(self):
     with mock.patch("__main__.__builtins__.open",
             mock.mock_open(read_data='hed,er\n1,2\n2,3\n3,4\n4,5')) \
             as mock_open:
         self.assertEqual(get_format("./non-existant"), "column-based")