Context için unittest.

Şimdilik yalnızca constness'ı test ediyoruz.
Daha sonra context'in yeni özelliklerini de test edeceğiz.
This commit is contained in:
Barış Metin
2005-06-16 11:03:16 +00:00
parent b600cc969c
commit bc163edb26
+44
View File
@@ -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)