示例#1
0
def test_include_taxa():

    # The taxon "var/assignment/explicit/single" is directly featured by assignment.py and
    # collatz.py, but only indirectly by the other programs, which therefore cannot be
    # included in the result. Note that this behavior contrasts with that of exclude_taxa.
    dbf = ProgramFilter(db)
    dbf.include_programs(
        dbf.programs_of_taxa({"var/assignment/explicit/single"}))
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"assignment.py", "collatz.py"}

    # "operator/arithmetic/addition" is directly featured by collatz.py only. Therefore,
    # including this taxon keeps only collatz.py.
    dbf = ProgramFilter(db)
    dbf.include_programs(dbf.programs_of_taxa({"operator/arithmetic/addition"
                                               }))
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"collatz.py"}

    # "flow/conditional" is featured by collatz.py, fizzbuzz.py, and indirectly by
    # is_even.py. Therefore, including this taxon keeps only the former two.
    dbf = ProgramFilter(db)
    dbf.include_programs(dbf.programs_of_taxa({"flow/conditional"}))
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"collatz.py", "fizzbuzz.py"}

    # "type/sequence/string/literal" is directly featured by fizzbuzz.py only. Therefore, including
    # this taxon keeps only fizzbuzz.py
    dbf = ProgramFilter(db)
    dbf.include_programs(dbf.programs_of_taxa({"type/sequence/string/literal"
                                               }))
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"fizzbuzz.py"}
示例#2
0
def test_include_programs():

    # The program collatz.py is self-contained. Including it has no other effect on the
    # selection.
    dbf = ProgramFilter(db)
    dbf.include_programs({"collatz.py"})
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"collatz.py"}

    # Including a program does not include the programs it imports.
    dbf = ProgramFilter(db)
    dbf.include_programs({"fizzbuzz.py"})
    print(dbf.selected_programs)
    assert dbf.selected_programs == {"fizzbuzz.py"}
示例#3
0
def test_include_programs():

    # The program collatz_print.py is self-contained. Including it has no other effect on the
    # selection.
    dbf = ProgramFilter(db)
    dbf.include_programs({"collatz_print.py"})
    print(set(dbf.selected_programs.keys()))
    assert set(dbf.selected_programs.keys()) == {"collatz_print.py"}

    # The program fizzbuzz.py imports collatz_print.py. Including the former includes both.
    dbf = ProgramFilter(db)
    dbf.include_programs({"fizzbuzz.py"})
    print(set(dbf.selected_programs.keys()))
    assert set(
        dbf.selected_programs.keys()) == {"fizzbuzz.py", "collatz_print.py"}

    # The program is_even.py import collatz_print.py, which imports collatz_print.py. Including the
    # former includes the three of them.
    dbf = ProgramFilter(db)
    dbf.include_programs({"is_even.py"})
    print(set(dbf.selected_programs.keys()))
    assert set(dbf.selected_programs.keys()) == {
        "is_even.py",
        "collatz_print.py",
        "fizzbuzz.py",
    }
def test_include_programs():
    dbf = ProgramFilter(db)
    programs = {"prg1.py", "prg2.py", "non_existing_program"}
    dbf.include_programs(programs)
    print(sorted(dbf.selected_programs))
    assert dbf.selected_programs.keys() == {"prg1.py", "prg2.py"}