/usr/lib/python2.3/tabnanny.py *

This commit is contained in:
S.Çağlar Onur
2005-06-21 14:29:16 +00:00
parent 83052cfb82
commit 3abf40413c
5 changed files with 84 additions and 93 deletions
+38 -39
View File
@@ -14,69 +14,68 @@ class ArchiveFileTestCase(unittest.TestCase):
# pass # pass
def testUnpackTar(self): def testUnpackTar(self):
ctx = context.Context("samples/popt/popt.pspec") ctx = context.Context("samples/popt/popt.pspec")
targetDir = ctx.pkg_work_dir() targetDir = ctx.pkg_work_dir()
fileName = os.path.basename(ctx.spec.source.archiveUri) fileName = os.path.basename(ctx.spec.source.archiveUri)
filePath = ctx.archives_dir() + '/' + fileName filePath = ctx.archives_dir() + '/' + fileName
achv = archive.Archive(filePath, ctx.spec.source.archiveType) achv = archive.Archive(filePath, ctx.spec.source.archiveType)
assert ctx.spec.source.archiveType == "targz" assert ctx.spec.source.archiveType == "targz"
# unpacking is trivial with Archive() # unpacking is trivial with Archive()
achv.unpack(targetDir) achv.unpack(targetDir)
# but testing is hard # but testing is hard
# "var/tmp/pisi/popt-1.7-3/work" (targetDir) # "var/tmp/pisi/popt-1.7-3/work" (targetDir)
assert pathexists(targetDir + "/popt-1.7") assert pathexists(targetDir + "/popt-1.7")
testfile = targetDir + "/popt-1.7/Makefile.am" testfile = targetDir + "/popt-1.7/Makefile.am"
assert pathexists(testfile) assert pathexists(testfile)
# check file integrity # check file integrity
self.assertEqual(util.sha1_file(testfile), self.assertEqual(util.sha1_file(testfile),
"5af9dd7d754f788cf511c57ce0af3d555fed009d") "5af9dd7d754f788cf511c57ce0af3d555fed009d")
def testUnpackZip(self): def testUnpackZip(self):
ctx = context.Context("tests/sandbox/sandbox.pspec") ctx = context.Context("tests/sandbox/sandbox.pspec")
fetch = fetcher.Fetcher(ctx) fetch = fetcher.Fetcher(ctx)
fetch.fetch() fetch.fetch()
targetDir = ctx.pkg_work_dir() targetDir = ctx.pkg_work_dir()
assert ctx.spec.source.archiveType == "zip" assert ctx.spec.source.archiveType == "zip"
fileName = os.path.basename(ctx.spec.source.archiveUri) fileName = os.path.basename(ctx.spec.source.archiveUri)
filePath = ctx.archives_dir() + '/' + fileName filePath = ctx.archives_dir() + '/' + fileName
achv = archive.Archive(filePath, ctx.spec.source.archiveType) achv = archive.Archive(filePath, ctx.spec.source.archiveType)
achv.unpack(targetDir) achv.unpack(targetDir)
assert pathexists(targetDir + "/sandbox") assert pathexists(targetDir + "/sandbox")
testfile = targetDir + "/sandbox/borek.cs" testfile = targetDir + "/sandbox/borek.cs"
assert pathexists(testfile) assert pathexists(testfile)
# check file integrity # check file integrity
self.assertEqual(util.sha1_file(testfile), self.assertEqual(util.sha1_file(testfile),
"06d0ee5ba49eccae6bc20552d55b3ba5ad52995e") "06d0ee5ba49eccae6bc20552d55b3ba5ad52995e")
# check for symbolic links # check for symbolic links
testfile = targetDir + "/sandbox/deneme/hed" testfile = targetDir + "/sandbox/deneme/hed"
assert islink(testfile) assert islink(testfile)
def testUnpackZipCond(self): def testUnpackZipCond(self):
ctx = context.Context("tests/sandbox/sandbox.pspec") ctx = context.Context("tests/sandbox/sandbox.pspec")
fetch = fetcher.Fetcher(ctx) fetch = fetcher.Fetcher(ctx)
fetch.fetch() fetch.fetch()
targetDir = ctx.pkg_work_dir() targetDir = ctx.pkg_work_dir()
assert ctx.spec.source.archiveType == "zip" assert ctx.spec.source.archiveType == "zip"
fileName = os.path.basename(ctx.spec.source.archiveUri) fileName = os.path.basename(ctx.spec.source.archiveUri)
filePath = ctx.archives_dir() + '/' + fileName filePath = ctx.archives_dir() + '/' + fileName
achv = archive.Archive(filePath, ctx.spec.source.archiveType) achv = archive.Archive(filePath, ctx.spec.source.archiveType)
achv.unpack_files(["sandbox/borek.cs"], targetDir) achv.unpack_files(["sandbox/borek.cs"], targetDir)
assert pathexists(targetDir + "/sandbox") assert pathexists(targetDir + "/sandbox")
testfile = targetDir + "/sandbox/borek.cs" testfile = targetDir + "/sandbox/borek.cs"
assert pathexists(testfile) assert pathexists(testfile)
suite = unittest.makeSuite(ArchiveFileTestCase) suite = unittest.makeSuite(ArchiveFileTestCase)
+27 -31
View File
@@ -5,40 +5,36 @@ from pisi import context
class ContextTestCase(unittest.TestCase): class ContextTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.ctx = context.Context("samples/popt/popt.pspec") self.ctx = context.Context("samples/popt/popt.pspec")
def testConstness(self): 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 if we can get a const attribute? # test binding a new constant
try: self.ctx.const.test = "test binding"
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) # test re-binding (which is illegal)
try: try:
self.ctx.const.test = "test rebinding" self.ctx.const.test = "test rebinding"
# we shouldn't reach here # we shouldn't reach here
self.fail("Rebinding a constant works. Something is wrong!") self.fail("Rebinding a constant works. Something is wrong!")
except: except:
# we achived our goal with this error. infact, this is a # we achived our goal with this error. infact, this is a
# ConstError but we can't catch it directly here # ConstError but we can't catch it directly here
pass 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
# 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) suite = unittest.makeSuite(ContextTestCase)
+5 -7
View File
@@ -8,16 +8,14 @@ from pisi import context
class FetcherTestCase(unittest.TestCase): class FetcherTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.ctx = context.Context("samples/popt/popt.pspec") self.ctx = context.Context("samples/popt/popt.pspec")
self.fetch = fetcher.Fetcher(self.ctx)
self.fetch = fetcher.Fetcher(self.ctx)
def testFetch(self): def testFetch(self):
self.fetch.fetch() self.fetch.fetch()
destpath = self.fetch.filedest + "/" + self.fetch.filename destpath = self.fetch.filedest + "/" + self.fetch.filename
if os.access(destpath, os.R_OK): if os.access(destpath, os.R_OK):
self.assertEqual(util.sha1_file(destpath), self.assertEqual(util.sha1_file(destpath),
self.ctx.spec.source.archiveSHA1) self.ctx.spec.source.archiveSHA1)
suite = unittest.makeSuite(FetcherTestCase) suite = unittest.makeSuite(FetcherTestCase)
+7 -8
View File
@@ -31,12 +31,11 @@ def run_all():
if __name__ == "__main__": if __name__ == "__main__":
args = sys.argv args = sys.argv
if len(args) > 1: # run modules given from the command line if len(args) > 1: # run modules given from the command line
tests = sys.argv[1:] tests = sys.argv[1:]
for test in tests: for test in tests:
module = __import__(test + 'tests') module = __import__(test + 'tests')
print "\nRunning tests in '%s'...\n" % (test) print "\nRunning tests in '%s'...\n" % (test)
runTestSuite(module.suite) runTestSuite(module.suite)
else: # run all tests else: # run all tests
print "\nRunning all tests in order...\n" print "\nRunning all tests in order...\n"
run_all() run_all()
+7 -8
View File
@@ -5,27 +5,26 @@ from pisi import specfile
class SpecReadTestCase(unittest.TestCase): class SpecReadTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = specfile.SpecFile() self.spec = specfile.SpecFile()
self.spec.read("samples/popt/popt.pspec") self.spec.read("samples/popt/popt.pspec")
def testSourceName(self): def testSourceName(self):
self.assertEqual(self.spec.source.name, self.assertEqual(self.spec.source.name,
"popt") "popt")
def testSourceVersion(self): def testSourceVersion(self):
self.assertEqual(self.spec.source.version, self.assertEqual(self.spec.source.version,
"1.7") "1.7")
def testSourceLastRelease(self): def testSourceLastRelease(self):
self.assertEqual(self.spec.source.release, self.assertEqual(self.spec.source.release,
"3") "3")
def testSHA1Sum(self): def testSHA1Sum(self):
self.assertEqual(self.spec.source.archiveSHA1, self.assertEqual(self.spec.source.archiveSHA1,
"66f3c77b87a160951b180447f4a6dce68ad2f71b") "66f3c77b87a160951b180447f4a6dce68ad2f71b")
def testLenPackages(self): def testLenPackages(self):
self.assertEqual(len(self.spec.packages), 1) self.assertEqual(len(self.spec.packages), 1)
suite = unittest.makeSuite(SpecReadTestCase) suite = unittest.makeSuite(SpecReadTestCase)