Skip to content

Commit ec5ce01

Browse files
authored
Merge pull request #242 from mvollrath/test_garbage
Test garbage collectability
2 parents 161e930 + 21632ff commit ec5ce01

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.travis.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
5-
- "3.2"
6-
- "3.3"
74
- "3.4"
85
- "3.5"
96
- "3.6"
7+
- "3.7"
108
- "nightly"
11-
- "pypy-5.3.1"
12-
- "pypy-5.4.1"
13-
# TODO: Enable pypy3 once NumPy is working there, see
14-
# https://bitbucket.org/pypy/pypy/issues/1567/
9+
- "pypy"
10+
# TODO: Enable pypy3 once NumPy is working there, see
11+
# https://bitbucket.org/pypy/pypy/issues/1567/
1512
#- "pypy3"
1613
addons:
1714
apt:
1815
packages:
1916
- libsndfile1
2017
install:
21-
- "if [[ $TRAVIS_PYTHON_VERSION == pypy* ]]; then pip install git+https://bitbucket.org/pypy/numpy.git ; fi"
18+
- "if [[ $TRAVIS_PYTHON_VERSION == pypy ]]; then pip install git+https://bitbucket.org/pypy/numpy.git ; fi"
2219
script:
2320
- python setup.py test

tests/test_pysoundfile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import pytest
77
import cffi
88
import sys
9+
import gc
10+
import weakref
911

1012
# floating point data is typically limited to the interval [-1.0, 1.0],
1113
# but smaller/larger values are supported as well
@@ -890,6 +892,14 @@ def test_anything_on_closed_file(file_stereo_r):
890892
assert "closed" in str(excinfo.value)
891893

892894

895+
def test_garbage(file_stereo_r):
896+
f = sf.SoundFile(file_stereo_r)
897+
ref = weakref.ref(f)
898+
f = None
899+
gc.collect()
900+
assert ref() is None
901+
902+
893903
def test_file_attributes_should_save_to_disk(file_w):
894904
with sf.SoundFile(file_w, 'w', 44100, 2, format='WAV') as f:
895905
f.title = 'testing'

0 commit comments

Comments
 (0)