summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/dep/test_get_operator.py
blob: 4f9848f5d7d921bf50cab60593a4dce6b420a2b6 (plain)
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_get_operator.py -- Portage Unit Testing Functionality
# Copyright 2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from portage.tests import TestCase
from portage.dep import get_operator

class GetOperator(TestCase):

	def testGetOperator(self):

		# get_operator does not validate operators
		tests = [ ( "~", "~" ), ( "=", "=" ), ( ">", ">" ),
			  ( ">=", ">=" ), ( "<=", "<=" ),
		]

		test_cpvs = ["sys-apps/portage-2.1"]
		slots = [ None,"1","linux-2.5.6" ]
		for cpv in test_cpvs:
			for test in tests:
				for slot in slots:
					atom = cpv[:]
					if slot:
						atom += ":" + slot
					result = get_operator( test[0] + atom )
					self.assertEqual( result, test[1],
						msg="get_operator(%s) != %s" % (test[0] + atom, test[1]) )

		result = get_operator( "sys-apps/portage" )
		self.assertEqual( result, None )

		result = get_operator( "=sys-apps/portage-2.1*" )
		self.assertEqual( result , "=*" )