Merge branch 'make-python-tests-run-independent-of-cwd' into 'master'
Make python tests run independent of cwd See merge request fdroid/fdroidserver!556
This commit is contained in:
commit
53bd5acb09
|
@ -2012,6 +2012,7 @@ def ensure_final_value(packageName, arsc, value):
|
|||
except (ValueError, TypeError):
|
||||
pass
|
||||
return returnValue
|
||||
return ''
|
||||
|
||||
|
||||
def is_apk_and_debuggable_aapt(apkfile):
|
||||
|
|
|
@ -57,7 +57,7 @@ class BuildTest(unittest.TestCase):
|
|||
|
||||
def test_force_gradle_build_tools(self):
|
||||
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
|
||||
shutil.copytree(os.path.join(os.path.dirname(__file__), 'source-files'),
|
||||
shutil.copytree(os.path.join('source-files'),
|
||||
os.path.join(testdir, 'source-files'))
|
||||
teststring = 'FAKE_VERSION_FOR_TESTING'
|
||||
fdroidserver.build.force_gradle_build_tools(testdir, teststring)
|
||||
|
@ -73,6 +73,8 @@ class BuildTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -54,6 +54,8 @@ class ExceptionTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -55,6 +55,8 @@ class ImportTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -95,7 +95,7 @@ class IndexTest(unittest.TestCase):
|
|||
head.return_value.headers = {'ETag': 'new_etag'}
|
||||
get.return_value.headers = {'ETag': 'new_etag'}
|
||||
get.return_value.status_code = 200
|
||||
testfile = os.path.join(os.path.dirname(__file__), 'signindex', 'guardianproject-v1.jar')
|
||||
testfile = os.path.join('signindex', 'guardianproject-v1.jar')
|
||||
with open(testfile, 'rb') as file:
|
||||
get.return_value.content = file.read()
|
||||
|
||||
|
@ -217,6 +217,8 @@ class IndexTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -35,6 +35,8 @@ class InstallTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -118,6 +118,8 @@ class LintTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -141,6 +141,8 @@ class MetadataTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -162,6 +162,8 @@ class PublishTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -39,6 +39,8 @@ class ScannerTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -57,6 +57,8 @@ class SignaturesTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
|
@ -174,7 +174,7 @@ class UpdateTest(unittest.TestCase):
|
|||
self.assertEqual(correctlocales, locales)
|
||||
|
||||
def javagetsig(self, apkfile):
|
||||
getsig_dir = os.path.join(os.path.dirname(__file__), 'getsig')
|
||||
getsig_dir = 'getsig'
|
||||
if not os.path.exists(getsig_dir + "/getsig.class"):
|
||||
logging.critical("getsig.class not found. To fix: cd '%s' && ./make.sh" % getsig_dir)
|
||||
sys.exit(1)
|
||||
|
@ -182,8 +182,8 @@ class UpdateTest(unittest.TestCase):
|
|||
config = dict()
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.common.config = config
|
||||
p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
|
||||
'getsig', os.path.join(os.getcwd(), apkfile)])
|
||||
p = FDroidPopen(['java', '-cp', 'getsig',
|
||||
'getsig', apkfile])
|
||||
sig = None
|
||||
for line in p.output.splitlines():
|
||||
if line.startswith('Result:'):
|
||||
|
@ -199,7 +199,7 @@ class UpdateTest(unittest.TestCase):
|
|||
config = dict()
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.update.config = config
|
||||
apkfile = os.path.join(os.path.dirname(__file__), 'urzip.apk')
|
||||
apkfile = 'urzip.apk'
|
||||
sig = self.javagetsig(apkfile)
|
||||
self.assertIsNotNone(sig, "sig is None")
|
||||
pysig = fdroidserver.update.getsig(apkfile)
|
||||
|
@ -222,12 +222,12 @@ class UpdateTest(unittest.TestCase):
|
|||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.update.config = config
|
||||
|
||||
apkfile = os.path.join(os.path.dirname(__file__), 'urzip-badsig.apk')
|
||||
apkfile = 'urzip-badsig.apk'
|
||||
sig = fdroidserver.update.getsig(apkfile)
|
||||
self.assertEqual(sig, 'e0ecb5fc2d63088e4a07ae410a127722',
|
||||
"python sig should be: " + str(sig))
|
||||
|
||||
apkfile = os.path.join(os.path.dirname(__file__), 'urzip-badcert.apk')
|
||||
apkfile = 'urzip-badcert.apk'
|
||||
sig = fdroidserver.update.getsig(apkfile)
|
||||
self.assertEqual(sig, 'e0ecb5fc2d63088e4a07ae410a127722',
|
||||
"python sig should be: " + str(sig))
|
||||
|
@ -303,7 +303,7 @@ class UpdateTest(unittest.TestCase):
|
|||
self.assertEqual(apk_info.get('versionName'), '0.9')
|
||||
|
||||
apk_info = fdroidserver.update.scan_apk('repo/duplicate.permisssions_9999999.apk')
|
||||
self.assertIsNone(apk_info.get('versionName'))
|
||||
self.assertEqual(apk_info.get('versionName'), '')
|
||||
self.assertEqual(apk_info['icons_src'], {'160': 'res/drawable/ic_launcher.png',
|
||||
'-1': 'res/drawable/ic_launcher.png'})
|
||||
|
||||
|
@ -673,6 +673,8 @@ class UpdateTest(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
|
|
Loading…
Reference in New Issue