From 3abf40413c5f6287d73c97b0e950c08a26e57f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Tue, 21 Jun 2005 14:29:16 +0000 Subject: [PATCH] /usr/lib/python2.3/tabnanny.py * --- tests/archivetests.py | 77 +++++++++++++++++++++--------------------- tests/contexttests.py | 58 +++++++++++++++---------------- tests/fetchertests.py | 12 +++---- tests/run.py | 15 ++++---- tests/specfiletests.py | 15 ++++---- 5 files changed, 84 insertions(+), 93 deletions(-) diff --git a/tests/archivetests.py b/tests/archivetests.py index 774f1fd0..409cc5fc 100644 --- a/tests/archivetests.py +++ b/tests/archivetests.py @@ -14,69 +14,68 @@ class ArchiveFileTestCase(unittest.TestCase): # pass 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) 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() - achv.unpack(targetDir) + # unpacking is trivial with Archive() + achv.unpack(targetDir) - # but testing is hard - # "var/tmp/pisi/popt-1.7-3/work" (targetDir) - assert pathexists(targetDir + "/popt-1.7") + # but testing is hard + # "var/tmp/pisi/popt-1.7-3/work" (targetDir) + assert pathexists(targetDir + "/popt-1.7") - testfile = targetDir + "/popt-1.7/Makefile.am" - assert pathexists(testfile) + testfile = targetDir + "/popt-1.7/Makefile.am" + assert pathexists(testfile) - # check file integrity - self.assertEqual(util.sha1_file(testfile), + # check file integrity + self.assertEqual(util.sha1_file(testfile), "5af9dd7d754f788cf511c57ce0af3d555fed009d") def testUnpackZip(self): - ctx = context.Context("tests/sandbox/sandbox.pspec") - fetch = fetcher.Fetcher(ctx) - fetch.fetch() + ctx = context.Context("tests/sandbox/sandbox.pspec") + fetch = fetcher.Fetcher(ctx) + 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) filePath = ctx.archives_dir() + '/' + fileName - achv = archive.Archive(filePath, ctx.spec.source.archiveType) - achv.unpack(targetDir) + achv = archive.Archive(filePath, ctx.spec.source.archiveType) + achv.unpack(targetDir) - assert pathexists(targetDir + "/sandbox") + assert pathexists(targetDir + "/sandbox") - testfile = targetDir + "/sandbox/borek.cs" - assert pathexists(testfile) + testfile = targetDir + "/sandbox/borek.cs" + assert pathexists(testfile) - # check file integrity - self.assertEqual(util.sha1_file(testfile), + # check file integrity + self.assertEqual(util.sha1_file(testfile), "06d0ee5ba49eccae6bc20552d55b3ba5ad52995e") - # check for symbolic links - testfile = targetDir + "/sandbox/deneme/hed" - assert islink(testfile) + # check for symbolic links + testfile = targetDir + "/sandbox/deneme/hed" + assert islink(testfile) def testUnpackZipCond(self): - ctx = context.Context("tests/sandbox/sandbox.pspec") - fetch = fetcher.Fetcher(ctx) - fetch.fetch() - targetDir = ctx.pkg_work_dir() - assert ctx.spec.source.archiveType == "zip" + ctx = context.Context("tests/sandbox/sandbox.pspec") + fetch = fetcher.Fetcher(ctx) + fetch.fetch() + targetDir = ctx.pkg_work_dir() + assert ctx.spec.source.archiveType == "zip" fileName = os.path.basename(ctx.spec.source.archiveUri) filePath = ctx.archives_dir() + '/' + fileName - achv = archive.Archive(filePath, ctx.spec.source.archiveType) - achv.unpack_files(["sandbox/borek.cs"], targetDir) - assert pathexists(targetDir + "/sandbox") - testfile = targetDir + "/sandbox/borek.cs" - assert pathexists(testfile) - + achv = archive.Archive(filePath, ctx.spec.source.archiveType) + achv.unpack_files(["sandbox/borek.cs"], targetDir) + assert pathexists(targetDir + "/sandbox") + testfile = targetDir + "/sandbox/borek.cs" + assert pathexists(testfile) suite = unittest.makeSuite(ArchiveFileTestCase) diff --git a/tests/contexttests.py b/tests/contexttests.py index e1bb6758..aeb41690 100644 --- a/tests/contexttests.py +++ b/tests/contexttests.py @@ -5,40 +5,36 @@ from pisi import context class ContextTestCase(unittest.TestCase): def setUp(self): - self.ctx = context.Context("samples/popt/popt.pspec") + self.ctx = context.Context("samples/popt/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 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 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 - - + # 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) diff --git a/tests/fetchertests.py b/tests/fetchertests.py index a67f7102..e5fb6dd8 100644 --- a/tests/fetchertests.py +++ b/tests/fetchertests.py @@ -8,16 +8,14 @@ from pisi import context class FetcherTestCase(unittest.TestCase): def setUp(self): - self.ctx = context.Context("samples/popt/popt.pspec") - - self.fetch = fetcher.Fetcher(self.ctx) + self.ctx = context.Context("samples/popt/popt.pspec") + self.fetch = fetcher.Fetcher(self.ctx) def testFetch(self): - self.fetch.fetch() - destpath = self.fetch.filedest + "/" + self.fetch.filename - if os.access(destpath, os.R_OK): + self.fetch.fetch() + destpath = self.fetch.filedest + "/" + self.fetch.filename + if os.access(destpath, os.R_OK): self.assertEqual(util.sha1_file(destpath), self.ctx.spec.source.archiveSHA1) - suite = unittest.makeSuite(FetcherTestCase) diff --git a/tests/run.py b/tests/run.py index 9ce62c5b..2ec516bc 100755 --- a/tests/run.py +++ b/tests/run.py @@ -31,12 +31,11 @@ def run_all(): if __name__ == "__main__": args = sys.argv if len(args) > 1: # run modules given from the command line - tests = sys.argv[1:] - for test in tests: - module = __import__(test + 'tests') - print "\nRunning tests in '%s'...\n" % (test) - runTestSuite(module.suite) - + tests = sys.argv[1:] + for test in tests: + module = __import__(test + 'tests') + print "\nRunning tests in '%s'...\n" % (test) + runTestSuite(module.suite) else: # run all tests - print "\nRunning all tests in order...\n" - run_all() + print "\nRunning all tests in order...\n" + run_all() diff --git a/tests/specfiletests.py b/tests/specfiletests.py index ca9d6b63..2f12022a 100644 --- a/tests/specfiletests.py +++ b/tests/specfiletests.py @@ -5,27 +5,26 @@ from pisi import specfile class SpecReadTestCase(unittest.TestCase): def setUp(self): - self.spec = specfile.SpecFile() - self.spec.read("samples/popt/popt.pspec") + self.spec = specfile.SpecFile() + self.spec.read("samples/popt/popt.pspec") def testSourceName(self): - self.assertEqual(self.spec.source.name, + self.assertEqual(self.spec.source.name, "popt") def testSourceVersion(self): - self.assertEqual(self.spec.source.version, + self.assertEqual(self.spec.source.version, "1.7") def testSourceLastRelease(self): - self.assertEqual(self.spec.source.release, + self.assertEqual(self.spec.source.release, "3") def testSHA1Sum(self): - self.assertEqual(self.spec.source.archiveSHA1, + self.assertEqual(self.spec.source.archiveSHA1, "66f3c77b87a160951b180447f4a6dce68ad2f71b") def testLenPackages(self): - self.assertEqual(len(self.spec.packages), 1) - + self.assertEqual(len(self.spec.packages), 1) suite = unittest.makeSuite(SpecReadTestCase)