aboutsummaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/util/test_stackDicts.py
blob: 0c1dcdb78b9b10c3250848dd5d5d2464cbc45897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# test_stackDicts.py -- Portage Unit Testing Functionality
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from portage.tests import TestCase
from portage.util import stack_dicts


class StackDictsTestCase(TestCase):

	def testStackDictsPass(self):

		tests = [
			([{'a': 'b'}, {'b': 'c'}], {'a': 'b', 'b': 'c'}, False, [], False),
			([{'a': 'b'}, {'a': 'c'}], {'a': 'b c'}, True, [], False),
			([{'a': 'b'}, {'a': 'c'}], {'a': 'b c'}, False, ['a'], False),
			([{'a': 'b'}, None], {'a': 'b'}, False, [], True),
			([None], {}, False, [], False),
			([None, {}], {}, False, [], True)
		]
		for test in tests:
			result = stack_dicts(test[0], test[2], test[3], test[4])
			self.assertEqual(result, test[1])

	def testStackDictsFail(self):

		tests = [
			([None, {}], None, False, [], True),
			([{'a': 'b'}, {'a': 'c'}], {'a': 'b c'}, False, [], False)
		]
		for test in tests:
			result = stack_dicts(test[0], test[2], test[3], test[4])
			self.assertNotEqual(result, test[1])