this file is part of audioread 2018 sam thursfield permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the software to deal in the software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense andor sell copies of the software and to permit persons to whom the software is furnished to do so subject to the following conditions the above notice and this permission notice shall be included in all copies or substantial portions of the software the audiofile fixture is defined in conftest py abort the read before it is completed this test guards against regressions such as https github combeetboxaudioreadpull78 now we exit the context manager without reading any data read the audio data from the file with audioread audioopenaudiofile path as a assert inta duration intaudiofile duration assert a channels audiofile channels assert a samplerate audiofile samplerate now read all the data and assert that it s the correct type for block in a assert typeblock bytes this file is part of audioread 2018 sam thursfield permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the software to deal in the software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and or sell copies of the software and to permit persons to whom the software is furnished to do so subject to the following conditions the above notice and this permission notice shall be included in all copies or substantial portions of the software the audiofile fixture is defined in conftest py abort the read before it is completed this test guards against regressions such as https github com beetbox audioread pull 78 now we exit the context manager without reading any data read the audio data from the file now read all the data and assert that it s the correct type
import audioread





def test_audioread_early_exit(audiofile):
    
    with audioread.audio_open(audiofile.path) as a:
        assert int(a.duration) == int(audiofile.duration)
        assert a.channels == audiofile.channels
        assert a.samplerate == audiofile.samplerate
        


def test_audioread_full(audiofile):
    
    with audioread.audio_open(audiofile.path) as a:
        assert int(a.duration) == int(audiofile.duration)
        assert a.channels == audiofile.channels
        assert a.samplerate == audiofile.samplerate

        
        for block in a:
            assert type(block) == bytes