Exemple #1
0
 def run(self, opts):
     from calibre.utils.run_tests import run_cli, filter_tests_by_name, remove_tests_by_name
     tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module))
     if opts.test_name:
         tests = filter_tests_by_name(tests, *opts.test_name)
     if opts.exclude_test_name:
         tests = remove_tests_by_name(tests, *opts.exclude_test_name)
     run_cli(tests, verbosity=opts.test_verbosity)
Exemple #2
0
 def run(self, opts):
     if opts.under_sanitize and 'CALIBRE_EXECED_UNDER_SANITIZE' not in os.environ:
         if 'libasan' not in os.environ.get('LD_PRELOAD', ''):
             os.environ['LD_PRELOAD'] = os.path.abspath(subprocess.check_output('gcc -print-file-name=libasan.so'.split()).decode('utf-8').strip())
         os.environ['CALIBRE_EXECED_UNDER_SANITIZE'] = '1'
         os.environ['ASAN_OPTIONS'] = 'detect_leaks=0'
         os.environ['PYCRYPTODOME_DISABLE_DEEPBIND'] = '1'  # https://github.com/Legrandin/pycryptodome/issues/558
         self.info(f'Re-execing with LD_PRELOAD={os.environ["LD_PRELOAD"]}')
         sys.stdout.flush()
         os.execl('setup.py', *sys.argv)
     from calibre.utils.run_tests import (
         filter_tests_by_name, remove_tests_by_name, run_cli
     )
     tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module))
     if opts.test_name:
         tests = filter_tests_by_name(tests, *opts.test_name)
     if opts.exclude_test_name:
         tests = remove_tests_by_name(tests, *opts.exclude_test_name)
     run_cli(tests, verbosity=opts.test_verbosity)
Exemple #3
0
 def run(self, opts):
     if opts.under_sanitize and 'libasan' not in os.environ.get(
             'LD_PRELOAD', ''):
         os.environ['LD_PRELOAD'] = os.path.abspath(
             subprocess.check_output(
                 'gcc -print-file-name=libasan.so'.split()).decode(
                     'utf-8').strip())
         os.environ['ASAN_OPTIONS'] = 'detect_leaks=0'
         self.info(f'Re-execing with LD_PRELOAD={os.environ["LD_PRELOAD"]}')
         sys.stdout.flush()
         os.execl('setup.py', *sys.argv)
     from calibre.utils.run_tests import (filter_tests_by_name,
                                          remove_tests_by_name, run_cli)
     tests = find_tests(which_tests=frozenset(opts.test_module),
                        exclude_tests=frozenset(opts.exclude_test_module))
     if opts.test_name:
         tests = filter_tests_by_name(tests, *opts.test_name)
     if opts.exclude_test_name:
         tests = remove_tests_by_name(tests, *opts.exclude_test_name)
     run_cli(tests, verbosity=opts.test_verbosity)
Exemple #4
0
def test():
    from calibre.utils.run_tests import run_cli
    run_cli(find_tests())
Exemple #5
0
 def run(self, opts):
     from calibre.utils.run_tests import run_cli, filter_tests_by_name
     tests = find_tests(which_tests=frozenset(opts.test_module))
     if opts.test_name:
         tests = filter_tests_by_name(tests, *opts.test_name)
     run_cli(tests, verbosity=opts.test_verbosity)
Exemple #6
0
            self.assert_cache_empty()
            self.ae(self.fetch_counter, 0)
            start_worker()
            stop_worker()
            self.ae(self.fetch_counter, 1)
            m = load_module('calibre.live', strategy=Strategy.fast)
            self.assertEqual(m.module_version, self.fetched_module_version)
            self.ae(self.fetch_counter, 1)
            m = load_module('calibre.live', strategy=Strategy.download_if_old)
            self.assertEqual(m.module_version, self.fetched_module_version)
            self.ae(self.fetch_counter, 1)
            m = load_module('calibre.live', strategy=Strategy.download_now)
            self.assertEqual(m.module_version, self.fetched_module_version)
            self.ae(self.fetch_counter, 2)
            old_interval = timedelta(days=-1)
            m = load_module('calibre.live', strategy=Strategy.download_if_old)
            self.assertEqual(m.module_version, self.fetched_module_version)
            self.ae(self.fetch_counter, 3)
            old_interval = self.orig_old_interval
            clear_cache()
            m = load_module('calibre.live', strategy=Strategy.download_if_old)
            self.assertEqual(m.module_version, self.fetched_module_version)
            self.ae(self.fetch_counter, 4)

    return unittest.defaultTestLoader.loadTestsFromTestCase(LiveTest)


if __name__ == '__main__':
    from calibre.utils.run_tests import run_cli
    run_cli(find_tests())
Exemple #7
0
def test():
    from calibre.utils.run_tests import run_cli
    run_cli(find_tests())
Exemple #8
0
                if isinstance(expected, type('')):
                    expected = [x.strip() for x in expected.split(',')]
                ans = map_tags(tags, rules)
                self.assertEqual(ans, expected)

            run(rule('capitalize', 't1,t2'), 't1,x1', 'T1,x1')
            run(rule('titlecase', 'some tag'), 'some tag,x1', 'Some Tag,x1')
            run(rule('upper', 'ta,t2'), 'ta,x1', 'TA,x1')
            run(rule('lower', 'ta,x1'), 'TA,X1', 'ta,x1')
            run(rule('replace', 't1', 't2'), 't1,x1', 't2,x1')
            run(rule('replace', '(.)1', r'\g<1>2', 'matches'), 't1,x1', 't2,x2')
            run(rule('replace', '(.)1', r'\g<1>2,3', 'matches'), 't1,x1', 't2,3,x2')
            run(rule('replace', 't1', 't2, t3'), 't1,x1', 't2,t3,x1')
            run([rule('replace', 't1', 't2,t3'), rule('remove', 't2')], 't1,x1', 't3,x1')
            run(rule('replace', 't1', 't1'), 't1,x1', 't1,x1')
            run([rule('replace', 't1', 't2'), rule('replace', 't2', 't1')], 't1,t2', 't1,t2')
            run(rule('replace', 'a', 'A'), 'a,b', 'A,b')
            run(rule('replace', 'a,b', 'A,B'), 'a,b', 'A,B')
            run(rule('replace', 'L', 'T', 'has'), 'L', 'T')
            run(rule('split', '/', '/', 'has'), 'a/b/c,d', 'a,b,c,d')
            run(rule('split', '/', '/', 'has'), '/,d', 'd')
            run(rule('split', '/', '/', 'has'), '/a/', 'a')
            run(rule('split', 'a,b', '/'), 'a,b', 'a,b')
            run(rule('split', 'a b', ' ', 'has'), 'a b', 'a,b')
    return unittest.defaultTestLoader.loadTestsFromTestCase(TestTagMapper)


if __name__ == '__main__':
    from calibre.utils.run_tests import run_cli
    run_cli(find_tests())