Exemplo n.º 1
0
def test_handle_arguments():
    expected = {
        "debug": False,
        "quiet": False,
        "output": ["recall-precision"],
        "chart_filetype": "pdf",
        "interpolation": True,
        "predictors": [],
        "exclude": "old",
        "profile": None,
        "training-file": "training"
    }

    args = handle_arguments(['training'])
    for k, v in expected.items():
        assert_equal(args[k], v)

    args = handle_arguments(['training', 'test'])
    for k, v in expected.items():
        assert_equal(args[k], v)
    assert_equal(args["test-file"], "test")

    argstr = "-p CommonNeighbours Cosine -o fmax " \
        "recall-precision -- training"
    args = handle_arguments(argstr.split())
    expected_special = {
        "predictors": ["CommonNeighbours", "Cosine"],
        "output": ["fmax", "recall-precision"]
    }
    for k, v in expected_special.items():
        assert_equal(args[k], v)

    args = handle_arguments(["training", "-i"])
    assert_equal(args["interpolation"], False)

    args = handle_arguments(["training", "-a"])
    assert_equal(args["exclude"], "")

    args = handle_arguments(["training", "-P", "foo.json"])
    assert_equal(args["profile"], "foo.json")

    args = handle_arguments(["training", "-f", "eps"])
    assert_equal(args["chart_filetype"], "eps")
Exemplo n.º 2
0
def test_handle_arguments():
    expected = {
        "debug": False,
        "quiet": False,
        "output": ["recall-precision"],
        "chart_filetype": "pdf",
        "interpolation": True,
        "predictors": [],
        "exclude": "old",
        "profile": None,
        "training-file": "training"
    }

    args = handle_arguments(['training'])
    for k, v in expected.items():
        assert_equal(args[k], v)

    args = handle_arguments(['training', 'test'])
    for k, v in expected.items():
        assert_equal(args[k], v)
    assert_equal(args["test-file"], "test")

    argstr = "-p CommonNeighbours Cosine -o fmax " \
        "recall-precision -- training"
    args = handle_arguments(argstr.split())
    expected_special = {"predictors": ["CommonNeighbours", "Cosine"],
                        "output": ["fmax", "recall-precision"]}
    for k, v in expected_special.items():
        assert_equal(args[k], v)

    args = handle_arguments(["training", "-i"])
    assert_equal(args["interpolation"], False)

    args = handle_arguments(["training", "-a"])
    assert_equal(args["exclude"], "")

    args = handle_arguments(["training", "-P", "foo.json"])
    assert_equal(args["profile"], "foo.json")

    args = handle_arguments(["training", "-f", "eps"])
    assert_equal(args["chart_filetype"], "eps")
Exemplo n.º 3
0
def test_nonexisting_predictor():
    sys.stderr = sys.stdout  # Suppress nose output to stderr
    handle_arguments(["some-network", "-p", "Aargh"])
Exemplo n.º 4
0
def test_no_training_file():
    sys.stderr = sys.stdout  # Suppress nose output to stderr
    handle_arguments([])
Exemplo n.º 5
0
def test_nonexisting_predictor():
    # Skip because nose always displays stderr output :-/
    raise nose.SkipTest()
    handle_arguments(["some-network", "-p", "Aargh"])
Exemplo n.º 6
0
def test_no_training_file():
    # Skip because nose always displays stderr output :-/
    raise nose.SkipTest()
    handle_arguments([])
Exemplo n.º 7
0
def test_nonexisting_predictor():
    sys.stderr = sys.stdout  # Suppress nose output to stderr
    handle_arguments(["some-network", "-p", "Aargh"])
Exemplo n.º 8
0
def test_no_training_file():
    sys.stderr = sys.stdout  # Suppress nose output to stderr
    handle_arguments([])
Exemplo n.º 9
0
def test_no_training_file():
    with pytest.raises(SystemExit):
        handle_arguments([])
Exemplo n.º 10
0
def test_nonexisting_predictor():
    with pytest.raises(SystemExit):
        handle_arguments(["some-network", "-p", "Aargh"])