Ignore:
Timestamp:
May 16, 2016, 5:08:18 AM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
a6f9ebf
Parents:
58a5fb9
Message:

python/tests: fix most prospect warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_source.py

    r58a5fb9 r0b6d23d  
    11#! /usr/bin/env python
    22
    3 from numpy.testing import TestCase, assert_equal, assert_almost_equal
    4 from aubio import fvec, source
    5 from numpy import array
     3from nose2 import main
     4from nose2.tools import params
     5from numpy.testing import TestCase
     6from aubio import source
    67from utils import list_all_sounds
    7 from nose2.tools import params
    88
    99list_of_sounds = list_all_sounds('sounds')
     
    4848        total_frames = 0
    4949        while True:
    50             vec, read = f()
     50            _ , read = f()
    5151            total_frames += read
    5252            if read < f.hop_size: break
    53         result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
    54         result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri
     53        #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
     54        #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri
    5555        #print (result_str.format(*result_params))
    5656        return total_frames
     
    102102        duration = f.duration
    103103        while True:
    104             vec, read = f()
     104            _, read = f()
    105105            total_frames += read
    106106            if read < f.hop_size: break
     
    112112    def test_wrong_file(self):
    113113        with self.assertRaises(RuntimeError):
    114             f = source('path_to/unexisting file.mp3')
     114            source('path_to/unexisting file.mp3')
    115115
    116116class aubio_source_test_wrong_params_with_file(aubio_source_test_case_base):
     
    118118    def test_wrong_samplerate(self):
    119119        with self.assertRaises(ValueError):
    120             f = source(self.default_test_sound, -1)
     120            source(self.default_test_sound, -1)
    121121
    122122    def test_wrong_hop_size(self):
    123123        with self.assertRaises(ValueError):
    124             f = source(self.default_test_sound, 0, -1)
     124            source(self.default_test_sound, 0, -1)
    125125
    126126    def test_wrong_channels(self):
    127127        with self.assertRaises(ValueError):
    128             f = source(self.default_test_sound, 0, 0, -1)
     128            source(self.default_test_sound, 0, 0, -1)
    129129
    130130    def test_wrong_seek(self):
     
    138138            with self.assertRaises(ValueError):
    139139                f.seek(f.duration + f.samplerate * 10)
    140         except AssertionError as e:
     140        except AssertionError:
    141141            self.skipTest('seeking after end of stream failed raising ValueError')
    142142
     
    146146        total_frames = 0
    147147        while True:
    148             vec, read = f.do_multi()
     148            _, read = f.do_multi()
    149149            total_frames += read
    150150            if read < f.hop_size: break
    151         result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
    152         result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri
     151        #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
     152        #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri
    153153        #print (result_str.format(*result_params))
    154154        return total_frames
    155155
    156156if __name__ == '__main__':
    157     from nose2 import main
    158157    main()
Note: See TracChangeset for help on using the changeset viewer.