From bc163edb26430376ea31b427645ac42212230fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Thu, 16 Jun 2005 11:03:16 +0000 Subject: [PATCH] =?UTF-8?q?Context=20i=C3=A7in=20unittest.=20=C5=9Eimdilik?= =?UTF-8?q?=20yaln=C4=B1zca=20constness'=C4=B1=20test=20ediyoruz.=20Daha?= =?UTF-8?q?=20sonra=20context'in=20yeni=20=C3=B6zelliklerini=20de=20test?= =?UTF-8?q?=20edece=C4=9Fiz.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/unittests/contexttests.py | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/unittests/contexttests.py diff --git a/src/unittests/contexttests.py b/src/unittests/contexttests.py new file mode 100644 index 00000000..353ece59 --- /dev/null +++ b/src/unittests/contexttests.py @@ -0,0 +1,44 @@ + +import unittest + +from pisi import context + +class ContextTestCase(unittest.TestCase): + def setUp(self): + self.ctx = context.Context("samples/popt.pspec") + + def testConstness(self): + + # test if we can get a const attribute? + try: + test = self.ctx.const.archives_dir_suffix + self.assertNotEqual(test, "") + except AttributeError: + self.fail("Couldn't get const attribute") + + # test binding a new constant + self.ctx.const.test = "test binding" + + # test re-binding (which is illegal) + try: + self.ctx.const.test = "test rebinding" + # we shouldn't reach here + self.fail("Rebinding a constant works. Something is wrong!") + except: + # we achived our goal with this error. infact, this is a + # ConstError but we can't catch it directly here + pass + + # test unbinding (which is also illegal) + try: + del self.ctx.const.test + # we shouldn't reach here + self.fail("Unbinding a constant works. Something is wrong!") + except: + # we achived our goal with this error. infact, this is a + # ConstError but we can't catch it directly here + pass + + + +suite = unittest.makeSuite(ContextTestCase)