class_docstr: Tests for the anomalyzer.
class_docstr_tok: ["Tests","for","the","anomalyzer","."]
code: def testSample(self):
      mockInput = MagicMock(return_value=StringIO(self.sampleInput))
      output = StringIO()
      mockOutput = MagicMock(return_value=output)
      with patch("__builtin__.open", mockInput):
          inputFile = FileRecordStream("input_path")
          with patch("__builtin__.open", mockOutput):
              outputFile = FileRecordStream(
                  "output_path",
                  fields=inputFile.getFields(),
                  write=True,
              )
              anomalyzer.sample(inputFile, outputFile, 1)
      result = StringIO(output.getvalue())
      result.next()
      result.next()
      result.next()
      reader = csv.reader(result)
      _, value = reader.next()
      self.assertIn(int(value), (1, 2, 3, 4, 5, 6))
      self.assertRaises(StopIteration, result.next)
  
file_path: nupic-legacy/tests/unit/nupic/data/generators/anomalyzer_test.py
imports: import csv
  from mock import MagicMock, patch
  from StringIO import StringIO
  import unittest2
  from nupic.data.file_record_stream import FileRecordStream
  from nupic.data.generators import anomalyzer
label_desc: Use image node_id 12 for calling the AnomalyzerTest obj's underlying member method code with example usage: obj.testSample() without return types