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")
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")
def test_nonexisting_predictor(): sys.stderr = sys.stdout # Suppress nose output to stderr handle_arguments(["some-network", "-p", "Aargh"])
def test_no_training_file(): sys.stderr = sys.stdout # Suppress nose output to stderr handle_arguments([])
def test_nonexisting_predictor(): # Skip because nose always displays stderr output :-/ raise nose.SkipTest() handle_arguments(["some-network", "-p", "Aargh"])
def test_no_training_file(): # Skip because nose always displays stderr output :-/ raise nose.SkipTest() handle_arguments([])
def test_no_training_file(): with pytest.raises(SystemExit): handle_arguments([])
def test_nonexisting_predictor(): with pytest.raises(SystemExit): handle_arguments(["some-network", "-p", "Aargh"])