Exemplo n.º 1
0
def test_bedtools_window_sm():
    """
    These two flags have almost the same name, and almost the same description
    """
    flags = [
        Flag(
            synonyms=["-sm"],
            description=
            "Only report hits in B that overlap A on the _same_ strand.",
            args=EmptyFlagArg(),
        ),
        Flag(
            synonyms=["-sm"],
            description=
            "Only report hits in B that overlap A on the _opposite_ strand.",
            args=EmptyFlagArg(),
        ),
        Flag(
            synonyms=["-c"],
            description=
            "For each entry in A, report the number of overlaps with B.",
            args=EmptyFlagArg(),
        ),
    ]
    args = WrapperGenerator().choose_variable_names(flags)
    assert len(set([arg.name for arg in args])) == 3
Exemplo n.º 2
0
def test_snake_short(snake_gen):
    flag = Flag(synonyms=["-t"],
                description="number of threads [1]",
                args=EmptyFlagArg())
    names = snake_gen.choose_variable_names([flag], length=2)
    assert "number" in names[0].name
    assert "threads" in names[0].name
Exemplo n.º 3
0
def test_snake_long(snake_gen):
    flag = Flag(
        synonyms=["-g", "--genomepaths", "--genomefolders"],
        description="number of threads [1]",
        args=EmptyFlagArg(),
    )
    names = snake_gen.choose_variable_names([flag], length=2)
    assert names[0].name == "genome_folders"
Exemplo n.º 4
0
def test_same_description():
    """
    Normally we ignore one-character flag names, and instead try to read their descriptions for a more informative name.
    However, if the descriptions are identical to each other, we have to fall back to the description
    """
    flags = [
        Flag(
            synonyms=["-a"],
            description="Makes the program do a certain thing",
            args=EmptyFlagArg(),
        ),
        Flag(
            synonyms=["-b"],
            description="Makes the program do a certain thing",
            args=EmptyFlagArg(),
        ),
    ]
    names = WrapperGenerator().choose_variable_names(flags)
    assert names[0].name == "a"
    assert names[1].name == "b"
Exemplo n.º 5
0
def test_name_to_words_symbol(gen):
    """
    Check that we can get an argument name even if the argument's flag is a symbol
    """
    arg = Flag(
        synonyms=["-@"],
        description="Number of additional threads to use",
        args=EmptyFlagArg(),
    )

    name = gen.choose_variable_names([arg])[0].name
    assert name == "at"
Exemplo n.º 6
0
def test_name_to_words(gen):
    """
    Check that we can get an argument name even if the argument's flag is a symbol
    """
    arg = Flag(
        synonyms=["--genomepaths"],
        description="",
        args=EmptyFlagArg(),
    )

    name = gen.choose_variable_names([arg])[0].name
    assert "genome" in name
    assert "paths" in name
Exemplo n.º 7
0
def test_camel_short(camel_gen):
    flag = Flag(synonyms=["-t"],
                description="number of threads [1]",
                args=EmptyFlagArg())
    names = camel_gen.choose_variable_names([flag], length=3)
    assert names[0].name == "numberOfThreads"
@pytest.mark.parametrize(
    "flag,typ",
    [
        [
            Flag(
                description=
                "Filename to output the counts to instead of stdout.",
                synonyms=["-c", "--counts_output"],
                args=SimpleFlagArg("OUTPUT_FILENAME"),
            ),
            CliFile(output=True),
        ],
        pytest.param(
            Flag(
                description=
                "redirect output to specified file\ndefault: undefined",
                synonyms=["-o"],
                args=EmptyFlagArg(),
            ),
            CliFile(output=True),
            marks=pytest.mark.xfail(
                reason=
                "Because the help doesn't indicate an argument, we can't know that this is an output file"
            ),
        ),
    ],
)
def test_flag_type_inference(flag: CliArgument, typ: CliType):
    inferred_type = flag.get_type()
    assert inferred_type == typ
Exemplo n.º 9
0
def visit_short_flag_list(s, loc, toks):
    return [
        Flag.from_synonyms(
            [FlagSynonym(name="-" + flag, argtype=EmptyFlagArg())],
            description=None) for flag in toks[1:]
    ]