summaryrefslogtreecommitdiffstats
path: root/tests/portage_dep/test_get_operator.py
blob: b2fa5965b3d462caaa526d4982b6d92a01d3f13f (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
# test_match_from_list.py -- Portage Unit Testing Functionality
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: test_atoms.py 5525 2007-01-10 13:35:03Z antarus $

from unittest import TestCase
from portage_dep import get_operator

class GetOperator(TestCase):

	def testGetOperator(self):

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

		testCP = "sys-apps/portage"

		for test in tests:
			result = get_operator( test[0] + testCP )
			self.failIf( result != test[1],
				msg="Expected %s from get_operator( %s ), got \
					%s" % ( test[1], test[0] + testCP, result ) )

		result = get_operator( "=sys-apps/portage*" )
		self.failIf( result != "=*",
				msg="Expected %s from get_operator( %s ), got \
					%s" % ( "=*", "=sys-apps/portage*", result ) )