|
21 | 21 | filename_new = 'tests/delme.please'
|
22 | 22 |
|
23 | 23 |
|
24 |
| -open_variants = 'name', 'fd', 'obj' |
25 |
| - |
| 24 | +if sys.version_info >= (3, 6): |
| 25 | + import pathlib |
| 26 | + open_variants = 'name', 'fd', 'obj', 'pathlib' |
| 27 | +else: |
| 28 | + open_variants = 'name', 'fd', 'obj' |
26 | 29 |
|
27 | 30 | xfail_from_buffer = pytest.mark.xfail(cffi.__version_info__ < (0, 9),
|
28 | 31 | reason="from_buffer() since CFFI 0.9")
|
|
31 | 34 | def _file_existing(request, filename, fdarg, objarg=None):
|
32 | 35 | if request.param == 'name':
|
33 | 36 | return filename
|
| 37 | + if request.param == 'pathlib': |
| 38 | + return pathlib.Path(filename) |
34 | 39 | elif request.param == 'fd':
|
35 | 40 | fd = os.open(filename, fdarg)
|
36 | 41 |
|
@@ -660,7 +665,8 @@ def test_seek_in_rplus_mode(sf_stereo_rplus):
|
660 | 665 |
|
661 | 666 | @pytest.mark.parametrize("use_default", [True, False])
|
662 | 667 | def test_truncate(file_stereo_rplus, use_default):
|
663 |
| - if isinstance(file_stereo_rplus, (str, int)): |
| 668 | + if (isinstance(file_stereo_rplus, (str, int)) |
| 669 | + or hasattr(file_stereo_rplus, '__fspath__')): |
664 | 670 | with sf.SoundFile(file_stereo_rplus, 'r+', closefd=False) as f:
|
665 | 671 | if use_default:
|
666 | 672 | f.seek(2)
|
|
0 commit comments