annotate hgext3rd/fastimport/vendor/python_fastimport/tests/test_helpers.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
1 # Copyright (C) 2009 Canonical Ltd
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
2 #
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
3 # This program is free software; you can redistribute it and/or modify
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
5 # the Free Software Foundation; either version 2 of the License, or
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
6 # (at your option) any later version.
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
7 #
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
8 # This program is distributed in the hope that it will be useful,
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
11 # GNU General Public License for more details.
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
12 #
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
15
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
16 """Test the helper functions."""
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
17
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
18 import unittest
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
19
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
20 from fastimport import (
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
21 helpers,
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
22 )
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
23
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
24
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
25 class TestCommonDirectory(unittest.TestCase):
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
26
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
27 def test_no_paths(self):
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
28 c = helpers.common_directory(None)
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
29 self.assertEqual(c, None)
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
30 c = helpers.common_directory([])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
31 self.assertEqual(c, None)
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
32
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
33 def test_one_path(self):
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
34 c = helpers.common_directory([b'foo'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
35 self.assertEqual(c, b'')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
36 c = helpers.common_directory([b'foo/'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
37 self.assertEqual(c, b'foo/')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
38 c = helpers.common_directory([b'foo/bar'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
39 self.assertEqual(c, b'foo/')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
40
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
41 def test_two_paths(self):
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
42 c = helpers.common_directory([b'foo', b'bar'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
43 self.assertEqual(c, b'')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
44 c = helpers.common_directory([b'foo/', b'bar'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
45 self.assertEqual(c, b'')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
46 c = helpers.common_directory([b'foo/', b'foo/bar'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
47 self.assertEqual(c, b'foo/')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
48 c = helpers.common_directory([b'foo/bar/x', b'foo/bar/y'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
49 self.assertEqual(c, b'foo/bar/')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
50 c = helpers.common_directory([b'foo/bar/aa_x', b'foo/bar/aa_y'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
51 self.assertEqual(c, b'foo/bar/')
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
52
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
53 def test_lots_of_paths(self):
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
54 c = helpers.common_directory([b'foo/bar/x', b'foo/bar/y', b'foo/bar/z'])
28704a2a7461 Import python-fastimport-0.9.8
Roy Marples <roy@marples.name>
parents:
diff changeset
55 self.assertEqual(c, b'foo/bar/')