class_docstr: Test decoding features
class_docstr_tok: ["Test","decoding","features"]
code: def tearDown(self):
      decoder = FileDecoder(
          uri=self.source, start=self.start, duration=self.duration
      )
  
      decoder.setup(
          samplerate=self.samplerate,
          channels=self.channels,
          blocksize=self.blocksize,
      )
  
      totalframes = 0
      compteur = 0
  
      while True:
          frames, eod = decoder.process()
          totalframes += frames.shape[0]
          compteur += 1
          if eod or decoder.eod:
              break
          self.assertEqual(frames.shape[0], decoder.blocksize())
          self.assertEqual(frames.shape[1], decoder.channels())
  
      ratio = decoder.output_samplerate / decoder.input_samplerate
      if 0:
          print(
              "input / output_samplerate:",
              decoder.input_samplerate,
              "/",
              decoder.output_samplerate,
          )
          print("ratio:", ratio)
          print(
              "input / output_channels:",
              decoder.input_channels,
              decoder.output_channels,
          )
          print("input_duration:", decoder.input_duration)
          print("uri_duration:", decoder.uri_duration)
          print("duration:", decoder.duration)
          print("input_totalframes:", decoder.input_totalframes)
          print("mime_type", decoder.mime_type())
  
      if self.channels:
          # when specified, check that the channels are the ones requested
          self.assertEqual(self.channels, decoder.output_channels)
      else:
          # otherwise check that the channels are preserved, if not specified
          self.assertEqual(
              decoder.input_channels, decoder.output_channels
          )
          # and if we know the expected channels, check the output match
          if self.expected_channels:
              self.assertEqual(
                  self.expected_channels, decoder.output_channels
              )
      # do the same with the sampling rate
      if self.samplerate:
          self.assertEqual(self.samplerate, decoder.output_samplerate)
      else:
          self.assertEqual(
              decoder.input_samplerate, decoder.output_samplerate
          )
          if self.expected_samplerate:
              self.assertEqual(
                  self.expected_samplerate, decoder.output_samplerate
              )
  
      self.assertEqual(decoder.mime_type(), self.expected_mime_type)
  
      expected_totalframes = int(
          decoder.input_duration * decoder.output_samplerate
      )
  
      # aubio estimates the total number of frames before resampling
      delta = 0
      if is_aubio:
          # delta = 0.1s
          delta = self.expected_samplerate // 10
          if self.expected_channels == 2:
              delta *= 2
      elif is_gstreamer:
          delta = 0
      self.assertAlmostEqual(
          totalframes, decoder.totalframes(), delta=delta
      )
  
      input_duration = (
          decoder.input_totalframes / decoder.input_samplerate
      )
      output_duration = (
          decoder.totalframes() / decoder.output_samplerate
      )
  
      if is_aubio:
          self.check_aubio(
              decoder,
              input_duration,
              output_duration,
              expected_totalframes,
          )
      elif is_gstreamer:
          self.check_gstreamer(
              decoder,
              input_duration,
              output_duration,
              expected_totalframes,
          )
      else:
          raise ValueError
  
file_path: TimeSide/tests/test_decoding.py
imports: from __future__ import division
  import unittest
  from unit_timeside import TestRunner
  from timeside.plugins.decoder.aubio import AubioDecoder
  from timeside.core.tools.test_samples import samples
label_desc: Use image node_id 8 for calling the TestDecoding obj's underlying member method code with example usage: obj.tearDown() without return types