class_docstr: Test encoding features
class_docstr_tok: ["Test","encoding","features"]
code: def tearDown(self):
      # Source through ArrayDecoder
  
      decoder = ArrayDecoder(
          self.generate_source(), samplerate=self.samplerate
      )
      # Encoder
      if not hasattr(self, "sink"):
          file_extension = "." + self.encoder_function.file_extension()
          self.sink = tmp_file_sink(
              prefix=self.__class__.__name__, suffix=file_extension
          )
      if not hasattr(self, "encoder"):
          self.encoder = self.encoder_function(
              self.sink, overwrite=self.overwrite
          )
  
      # Run Pipe
      (decoder | self.encoder).run()
  
      if self.encode_to_file:
          media_info = get_media_uri_info(get_uri(self.sink))
          media_duration = media_info["duration"]
          media_channels = media_info["streams"][0]["channels"]
          media_samplerate = media_info["streams"][0]["samplerate"]
  
          if self.test_duration:
              self.assertAlmostEqual(
                  self.source_duration, media_duration, delta=self.delta
              )
          if self.test_channels:
              self.assertEqual(self.channels, media_channels)
          else:
              self.assertEqual(2, media_channels)  # voaacenc bug ?
          self.assertEqual(media_samplerate, self.samplerate)
  
          os.unlink(self.sink)
  
      if 0:
          import commands
  
          print(commands.getoutput("sndfile-info " + self.sink))
  
      self.assertEqual(
          self.expected_total_frames, self.encoder.num_samples
      )
      self.assertEqual(self.channels, self.encoder.channels())
      self.assertEqual(self.samplerate, self.encoder.samplerate())
      self.assertEqual(
          self.source_duration,
          self.encoder.num_samples / self.encoder.samplerate(),
      )
  
imports: from __future__ import division
  from math import pi
  import numpy
  from unit_timeside import *
  from timeside.plugins.decoder.utils import get_uri, get_media_uri_info
  from timeside.plugins.decoder.array import ArrayDecoder
  import os
  from tools import tmp_file_sink
label_desc: Use image node_id 14 for calling the TestEncoding obj's underlying member method code with example usage: obj.tearDown() without return types