Exemple #1
0
def test_oneline():
    from bionic.utils.misc import oneline

    assert oneline("one two") == "one two"
    assert oneline(" one two ") == "one two"
    assert oneline("\none\ntwo") == "one two"
    assert (oneline("""
       one
       two   three""") == "one two   three")
    assert (oneline("""
       one
       two

       three
       """) == "one two three")
 def y():
     return oneline("Use a function in another module")
Exemple #3
0
def pytest_collection_modifyitems(config, items):
    also_run_slow = config.getoption("--slow")
    skip_slow = pytest.mark.skip(reason="only runs when --slow is set")

    has_gcs = config.getoption("--bucket")
    skip_needs_gcs = pytest.mark.skip(reason="only runs when --bucket is set")

    has_aip = has_gcs and config.getoption("--aip")
    skip_needs_aip = pytest.mark.skip(
        reason="only runs when both --bucket and --aip are set")

    also_run_parallel = config.getoption("--parallel")

    items_to_keep = []
    for item in items:
        item_is_baseline = True

        if "slow" in item.keywords:
            item_is_baseline = False
            if not also_run_slow:
                item.add_marker(skip_slow)

        if "real_gcp" in item.keywords:
            if "fake_gcp_only" in item.keywords:
                continue

            if "needs_gcs" in item.keywords:
                item_is_baseline = False
                if not has_gcs:
                    item.add_marker(skip_needs_gcs)

            if "needs_aip" in item.keywords:
                item_is_baseline = False
                if not has_aip:
                    item.add_marker(skip_needs_aip)

        elif "fake_gcp" in item.keywords:
            if "real_gcp_only" in item.keywords:
                continue

        if "parallel" in item.keywords:
            if "allows_parallel" not in item.keywords:
                item_is_baseline = False

                if "no_parallel" in item.keywords or not also_run_parallel:
                    continue

        elif "needs_parallel" in item.keywords:
            continue

        if "needs_aip_and_docker_commit_access" in item.keywords:
            if not has_aip:
                item.add_marker(skip_needs_aip)
            elif not is_current_commit_remotely_available():
                item.add_marker(
                    pytest.mark.skip(reason=oneline("""
                        only runs when --bucket and --aip are set and the
                        current git commit is available for access by docker
                        build; that means the commit is pushed to the remote
                        repository
                    """)))

        if item_is_baseline:
            item.add_marker(pytest.mark.baseline)

        items_to_keep.append(item)

    items.clear()
    items.extend(items_to_keep)