comparison hgext3rd/fastimport/vendor/python_fastimport/tests/test_errors.py @ 86:28704a2a7461 vendor/python-fastimport

Import python-fastimport-0.9.8
author Roy Marples <roy@marples.name>
date Tue, 19 Jan 2021 22:56:34 +0000
parents
children
comparison
equal deleted inserted replaced
85:1f5544a8870b 86:28704a2a7461
1 # Copyright (C) 2008 Canonical Ltd
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 """Test the Import errors"""
17 from unittest import TestCase
18
19 from fastimport import (
20 errors,
21 )
22
23
24 class TestErrors(TestCase):
25
26 def test_MissingBytes(self):
27 e = errors.MissingBytes(99, 10, 8)
28 self.assertEqual("line 99: Unexpected EOF - expected 10 bytes, found 8",
29 str(e))
30
31 def test_MissingTerminator(self):
32 e = errors.MissingTerminator(99, '---')
33 self.assertEqual("line 99: Unexpected EOF - expected '---' terminator",
34 str(e))
35
36 def test_InvalidCommand(self):
37 e = errors.InvalidCommand(99, 'foo')
38 self.assertEqual("line 99: Invalid command 'foo'",
39 str(e))
40
41 def test_MissingSection(self):
42 e = errors.MissingSection(99, 'foo', 'bar')
43 self.assertEqual("line 99: Command foo is missing section bar",
44 str(e))
45
46 def test_BadFormat(self):
47 e = errors.BadFormat(99, 'foo', 'bar', 'xyz')
48 self.assertEqual("line 99: Bad format for section bar in "
49 "command foo: found 'xyz'",
50 str(e))
51
52 def test_InvalidTimezone(self):
53 e = errors.InvalidTimezone(99, 'aa:bb')
54 self.assertEqual('aa:bb', e.timezone)
55 self.assertEqual('', e.reason)
56 self.assertEqual("line 99: Timezone 'aa:bb' could not be converted.",
57 str(e))
58 e = errors.InvalidTimezone(99, 'aa:bb', 'Non-numeric hours')
59 self.assertEqual('aa:bb', e.timezone)
60 self.assertEqual(' Non-numeric hours', e.reason)
61 self.assertEqual("line 99: Timezone 'aa:bb' could not be converted."
62 " Non-numeric hours",
63 str(e))
64
65 def test_UnknownDateFormat(self):
66 e = errors.UnknownDateFormat('aaa')
67 self.assertEqual("Unknown date format 'aaa'", str(e))
68
69 def test_MissingHandler(self):
70 e = errors.MissingHandler('foo')
71 self.assertEqual("Missing handler for command foo", str(e))
72
73 def test_UnknownFeature(self):
74 e = errors.UnknownFeature('aaa')
75 self.assertEqual("Unknown feature 'aaa' - try a later importer or "
76 "an earlier data format", str(e))