X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=tests%2Fscanner.TestCase;h=b0d2dc52fb243ce35dca30465cdbaa3581d37610;hb=39b76b0eda1b6e5b3aa1c9bbdcc3d5f4b4d10c81;hp=874d1ad44b43dbb74371549587d0c7a2dcbfc20d;hpb=86c5598307584b14853db6116e3a6fe090f43e47;p=fdroidserver.git diff --git a/tests/scanner.TestCase b/tests/scanner.TestCase index 874d1ad4..b0d2dc52 100755 --- a/tests/scanner.TestCase +++ b/tests/scanner.TestCase @@ -1,25 +1,41 @@ #!/usr/bin/env python3 -import unittest +import glob +import inspect +import logging import optparse -from pathlib import Path -from os.path import basename, dirname, realpath +import os +import sys +import unittest + +localmodule = os.path.realpath( + os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')) +print('localmodule: ' + localmodule) +if localmodule not in sys.path: + sys.path.insert(0, localmodule) -from fdroidserver import scanner -from fdroidserver.metadata import Build import fdroidserver.common +import fdroidserver.metadata +import fdroidserver.scanner class ScannerTest(unittest.TestCase): + + def setUp(self): + logging.basicConfig(level=logging.INFO) + self.basedir = os.path.join(localmodule, 'tests') + def test_scan_source_files(self): - source_files = Path(dirname(realpath(__file__)), 'source-files') + source_files = os.path.join(self.basedir, 'source-files') projects = { 'Zillode': 1, 'firebase-suspect': 1 } - for d in (str(p) for p in source_files.iterdir()): - fatal_problems = scanner.scan_source(d, Build()) - self.assertEqual(projects.get(basename(d), 0), fatal_problems) + for d in glob.glob(os.path.join(source_files, '*')): + build = fdroidserver.metadata.Build() + fatal_problems = fdroidserver.scanner.scan_source(d, build) + self.assertEqual(projects.get(os.path.basename(d), 0), + fatal_problems) if __name__ == "__main__":