Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_by_name_3():
"""Assert that get_by_name raises ValueError with duplicate operators in operator dictionary."""
# no duplicate
ret_op_class = get_by_name("SelectPercentile", tpot_obj.operators)
# add a copy of TPOTSelectPercentile into operator list
tpot_obj.operators.append(TPOTSelectPercentile)
assert_raises(ValueError, get_by_name, "SelectPercentile", tpot_obj.operators)
def test_get_by_name():
"""Assert that the Operator class returns operators by name appropriately."""
assert get_by_name("SelectPercentile", tpot_obj.operators).__class__ == TPOTSelectPercentile.__class__
assert get_by_name("SelectFromModel", tpot_obj.operators).__class__ == TPOTSelectFromModel.__class__
def test_get_by_name():
"""Assert that the Operator class returns operators by name appropriately."""
assert get_by_name("SelectPercentile", tpot_obj.operators).__class__ == TPOTSelectPercentile.__class__
assert get_by_name("SelectFromModel", tpot_obj.operators).__class__ == TPOTSelectFromModel.__class__
def test_get_by_name_2():
"""Assert that get_by_name raises TypeError with a incorrect operator name."""
assert_raises(TypeError, get_by_name, "RandomForestRegressor", tpot_obj.operators)
# use correct name
ret_op_class = get_by_name("RandomForestClassifier", tpot_obj.operators)