class_docstr: Test DecisionBoundariesVisualizer
class_docstr_tok: ["Test","DecisionBoundariesVisualizer"]
docstr: Testing the fit method works as expected
docstr_tok: ["Testing","the","fit","method","works","as","expected"]
code: def test_fit(self):
      """
      Testing the fit method works as expected
      """
      model = neighbors.KNeighborsClassifier(3)
      model.fit = mock.MagicMock()
      model.predict = mock.MagicMock()
  
      viz = DecisionBoundariesVisualizer(model)
      fitted_viz = viz.fit(X_two_cols, y=y)
  
      # assert that classes and labels are established
      assert fitted_viz.classes_ == {0: "0", 1: "1", 2: "2", 3: "3"}
      assert fitted_viz.features_ == ["Feature One", "Feature Two"]
  
      # assert that the fit method is called
      model.fit.assert_called_once_with(X_two_cols, y)
      # mock object is called twice in predict and reshape
      assert len(model.predict.mock_calls) == 2
  
      # test that attrs are set
      assert fitted_viz.ax is not None
      assert fitted_viz.Z_shape is not None
  
imports: import sys
  import pytest
  import numpy
  from unittest import mock
  from tests.base import VisualTestCase
  from yellowbrick.contrib.classifier import *
  from yellowbrick.exceptions import YellowbrickTypeError
  from yellowbrick.exceptions import YellowbrickValueError
  from sklearn import datasets
  from sklearn import neighbors
  from sklearn import naive_bayes
label_desc: Use image node_id 5 for calling the TestDecisionBoundariesVisualizer obj's underlying member method code with example usage: obj.test_fit() without return types