Esempio n. 1
0
def _():
    one = Test(fn=named, module_name="", tags=["apples", "bananas"])
    two = Test(fn=named, module_name="", tags=["bananas", "carrots"])
    three = Test(fn=named, module_name="", tags=["bananas"])
    tag_expr = parse("apples or bananas and not carrots")
    results = list(search_generally([one, two, three], tag_expr=tag_expr))
    assert results == [one, three]
Esempio n. 2
0
def _():
    one = Test(fn=named, module_name="one", tags=["apples"])
    two = Test(fn=named, module_name="two", tags=["apples"])
    tag_expr = parse("apples")
    results = list(search_generally([one, two], query="two",
                                    tag_expr=tag_expr))
    # Both tests match the tag expression, but only two matches the search query
    # because the query matches the module name for the test.
    assert results == [two]
Esempio n. 3
0
def test(
    ctx: click.Context,
    config: str,
    config_path: Optional[Path],
    path: Tuple[str],
    exclude: Tuple[str],
    search: Optional[str],
    tags: Optional[Expression],
    fail_limit: Optional[int],
    test_output_style: str,
    order: str,
    capture_output: bool,
    show_slowest: int,
    show_diff_symbols: bool,
    dry_run: bool,
):
    """Run tests."""
    start_run = default_timer()
    paths = [Path(p) for p in path]
    mod_infos = get_info_for_modules(paths, exclude)
    modules = list(load_modules(mod_infos))
    unfiltered_tests = get_tests_in_modules(modules, capture_output)
    tests = list(
        search_generally(
            unfiltered_tests,
            query=search,
            tag_expr=tags,
        ))

    # Rewrite assertions in each test
    tests = rewrite_assertions_in_tests(tests)

    time_to_collect = default_timer() - start_run

    suite = Suite(tests=tests)
    test_results = suite.generate_test_runs(order=order, dry_run=dry_run)

    writer = SimpleTestResultWrite(
        suite=suite,
        test_output_style=test_output_style,
        config_path=config_path,
        show_diff_symbols=show_diff_symbols,
    )
    writer.output_header(time_to_collect=time_to_collect)
    results = writer.output_all_test_results(test_results,
                                             fail_limit=fail_limit)
    time_taken = default_timer() - start_run
    writer.output_test_result_summary(results, time_taken, show_slowest)

    exit_code = get_exit_code(results)

    sys.exit(exit_code.value)
Esempio n. 4
0
def run(path, search, fail_limit):
    start_run = default_timer()

    mod_infos = get_info_for_modules(path)
    modules = list(load_modules(mod_infos))
    unfiltered_tests = get_tests_in_modules(modules)
    tests = search_generally(unfiltered_tests, query=search)
    time_to_collect = default_timer() - start_run

    suite = Suite(tests=list(tests))
    test_results = suite.generate_test_runs()

    writer = SimpleTestResultWrite(suite=suite)
    results = writer.output_all_test_results(test_results,
                                             time_to_collect=time_to_collect,
                                             fail_limit=fail_limit)
    time_taken = default_timer() - start_run
    writer.output_test_result_summary(results, time_taken)

    exit_code = get_exit_code(results)

    sys.exit(exit_code.value)
Esempio n. 5
0
def run(
    ctx: click.Context,
    path: Tuple[str],
    exclude: Tuple[str],
    search: Optional[str],
    fail_limit: Optional[int],
    test_output_style: str,
    order: str,
    capture_output: bool,
    config: str,
    show_slowest: int,
):
    start_run = default_timer()
    paths = [Path(p) for p in path]
    mod_infos = get_info_for_modules(paths, exclude)
    modules = list(load_modules(mod_infos))
    unfiltered_tests = get_tests_in_modules(modules, capture_output)
    tests = list(search_generally(unfiltered_tests, query=search))

    # Rewrite assertions in each test
    tests = rewrite_assertions_in_tests(tests)

    time_to_collect = default_timer() - start_run

    suite = Suite(tests=tests)
    test_results = suite.generate_test_runs(order=order)

    writer = SimpleTestResultWrite(suite=suite,
                                   test_output_style=test_output_style)
    results = writer.output_all_test_results(test_results,
                                             time_to_collect=time_to_collect,
                                             fail_limit=fail_limit)
    time_taken = default_timer() - start_run
    writer.output_test_result_summary(results, time_taken, show_slowest)

    exit_code = get_exit_code(results)

    sys.exit(exit_code.value)
Esempio n. 6
0
def _(tests=tests_to_search):
    results = search_generally(tests, query="92qj3f9i")
    with raises(StopIteration):
        next(results)
Esempio n. 7
0
def _(tests=tests_to_search, named=named_test):
    results = search_generally(tests, query="fox")
    expect(list(results)).equals([named])
Esempio n. 8
0
def _(tests=tests_to_search, named=named_test):
    results = search_generally(tests, query="fox")
    assert list(results) == [named]
Esempio n. 9
0
def _():
    t = Test(fn=named, module_name="", tags=[])
    tag_expr = parse("apples")
    results = list(search_generally([t], tag_expr=tag_expr))
    assert results == []
Esempio n. 10
0
def _():
    apples = Test(fn=named, module_name="", tags=["apples"])
    bananas = Test(fn=named, module_name="", tags=["bananas"])
    results = list(
        search_generally([apples, bananas], tag_expr=parse("apples")))
    assert results == [apples]
Esempio n. 11
0
def _():
    one = Test(fn=named, module_name="one", tags=["apples"])
    two = Test(fn=named, module_name="two", tags=["bananas"])
    tag_expr = parse("carrots")
    results = list(search_generally([one, two], tag_expr=tag_expr))
    assert results == []