diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-09-12 22:52:19 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-09-12 22:52:19 +0000 |
commit | cb78871ec00fb0647076540318b9fb2d11f22363 (patch) | |
tree | 4cbe21f3efacd0510ac2a97a0e9b927dd89a8aa7 | |
parent | 4dd359e876b6bcac2bddcb5eb2c508ca2fb67f66 (diff) | |
download | portage-cb78871ec00fb0647076540318b9fb2d11f22363.tar.gz portage-cb78871ec00fb0647076540318b9fb2d11f22363.tar.bz2 portage-cb78871ec00fb0647076540318b9fb2d11f22363.zip |
Add tests for the Atom class.
svn path=/main/trunk/; revision=14238
-rw-r--r-- | pym/portage/tests/dep/testAtom.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/testAtom.py b/pym/portage/tests/dep/testAtom.py new file mode 100644 index 000000000..c527bb7d2 --- /dev/null +++ b/pym/portage/tests/dep/testAtom.py @@ -0,0 +1,42 @@ +# test_isvalidatom.py -- Portage Unit Testing Functionality +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from portage.tests import TestCase +from portage.dep import Atom +import portage.dep +portage.dep._dep_check_strict = True + +class TestAtom(TestCase): + """ A simple testcase for isvalidatom + """ + + def testAtom(self): + + tests = [ + ( "=sys-apps/portage-2.1-r1:0[doc]", + ('=', 'sys-apps/portage', '2.1-r1', '0', '[doc]') ), + ( "=sys-apps/portage-2.1-r1*:0[doc]", + ('=*', 'sys-apps/portage', '2.1-r1', '0', '[doc]') ), + ( "sys-apps/portage:0[doc]", + (None, 'sys-apps/portage', None, '0', '[doc]') ), + ] + + for atom, parts in tests: + a = Atom(atom) + op, cp, ver, slot, use = parts + self.assertEqual( op, a.operator, + msg="Atom('%s').operator == '%s'" % ( atom, a.operator ) ) + self.assertEqual( cp, a.cp, + msg="Atom('%s').cp == '%s'" % ( atom, a.cp ) ) + if ver is not None: + cpv = "%s-%s" % (cp, ver) + else: + cpv = cp + self.assertEqual( cpv, a.cpv, + msg="Atom('%s').cpv == '%s'" % ( atom, a.cpv ) ) + self.assertEqual( slot, a.slot, + msg="Atom('%s').slot == '%s'" % ( atom, a.slot ) ) + self.assertEqual( use, str(a.use), + msg="Atom('%s').use == '%s'" % ( atom, a.use ) ) |