Skip to content

Commit

Permalink
add tests for filter wlbl, remove todos
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanKepner committed Apr 1, 2019
1 parent 96ea74f commit e0ecf2b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
5 changes: 0 additions & 5 deletions mutatest/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,6 @@ def run_mutation_trials( # noqa: C901

LOGGER.info("Current target location: %s, %s", Path(sample_src).name, sample_idx)

# TODO: THIS IS THE WHITELIST/BLACKLIST CATEGORY TARGET FOR 0.9.1-DEV
# TODO: HOW TO APPROPRIATELY REPORT SKIPPING? RETURN NONE IF SKIPPED CATEGORY?
# TODO: LIKELY A COUNTER, ADD TO THE RESULTS SUMMARY
# TODO: SAMPLE IS ALREADY CREATED AT THIS POINT, SO MAY NEED TO MOVE HIGHER IN LOGIC TO
# TODO: CORRECTLY FULFILL THE N-LOCATIONS ARGUMENT
mutant_operations = get_mutations_for_target(sample_idx)
src_tree = src_trees[sample_src]

Expand Down
31 changes: 31 additions & 0 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

from pathlib import Path
from subprocess import CompletedProcess
from typing import NamedTuple, Set

import hypothesis.strategies as st
import pytest

from hypothesis import assume, example, given

import mutatest.controller

from mutatest.controller import (
BaselineTestException,
build_src_trees_and_targets,
clean_trial,
colorize_output,
filter_wl_bl_categories,
get_mutation_sample_locations,
get_py_files,
get_sample_space,
Expand Down Expand Up @@ -187,6 +191,33 @@ def test_optimize_covered_sample(mock_coverage_file, mock_precov_sample):
assert li.lineno in [1, 4, 2]


class MockOp(NamedTuple):
category: str
operations: Set[str]


def test_filter_wl_bl_categories(monkeypatch):
"""Filtering based on op return expectations."""

def mock_get_comp_ops(*args, **kwargs):
return [MockOp("aa", {"a1", "a2"}), MockOp("bb", {"b1", "b2"}), MockOp("cc", {"c1", "c2"})]

monkeypatch.setattr(mutatest.controller, "get_compatible_operation_sets", mock_get_comp_ops)

sample = [
("a1", LocIndex(ast_class="a", lineno=1, col_offset=2, op_type="a1")),
("a2", LocIndex(ast_class="a", lineno=1, col_offset=2, op_type="a2")),
("b1", LocIndex(ast_class="a", lineno=1, col_offset=2, op_type="b1")),
("c1", LocIndex(ast_class="a", lineno=1, col_offset=2, op_type="c1")),
]

result = filter_wl_bl_categories(sample_space=sample, wlbl_categories={"aa"})

assert len(result) == 2
for i, _ in result:
assert i.startswith("a")


####################################################################################################
# PROPERTY TESTS
####################################################################################################
Expand Down

0 comments on commit e0ecf2b

Please sign in to comment.