/usr/lib/python2.3/tabnanny.py *
This commit is contained in:
+38
-39
@@ -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)
|
||||
|
||||
+27
-31
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+7
-8
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user