Skip to content

Commit

Permalink
Merge pull request #424 from sbraz/test_copy_sendfile
Browse files Browse the repository at this point in the history
Do not test the patched copy implementation with Python 3.8+, fixes #421
  • Loading branch information
althonos committed Sep 17, 2020
2 parents 63a14f7 + 5df7f7d commit 3e02968
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Start testing on PyPy. Due to [#342](https://github.com/PyFilesystem/pyfilesystem2/issues/342)
we have to treat PyPy builds specially and allow them to fail, but at least we'll
be able to see if we break something aside from known issues with FTP tests.
- Stop patching copy with Python 3.8+ because it already uses sendfile.

## [2.4.11] - 2019-09-07

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Many thanks to the following developers for contributing to this project:
- [Diego Argueta](https://github.com/dargueta)
- [Geoff Jukes](https://github.com/geoffjukes)
- [Giampaolo](https://github.com/gpcimino)
- [Louis Sautier](https://github.com/sbraz)
- [Martin Larralde](https://github.com/althonos)
- [Will McGugan](https://github.com/willmcgugan)
- [Zmej Serow](https://github.com/zmej-serow)
2 changes: 1 addition & 1 deletion fs/osfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def _check_copy(self, src_path, dst_path, overwrite=False):
raise errors.DirectoryExpected(dirname(dst_path))
return _src_path, _dst_path

if sys.version_info[:2] <= (3, 8) and sendfile is not None:
if sys.version_info[:2] < (3, 8) and sendfile is not None:

_sendfile_error_codes = {
errno.EIO,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_osfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import shutil
import tempfile
import sys
import unittest
import pytest

Expand Down Expand Up @@ -88,6 +89,11 @@ def test_expand_vars(self):
self.assertNotIn("TYRIONLANISTER", fs2.getsyspath("/"))

@pytest.mark.skipif(osfs.sendfile is None, reason="sendfile not supported")
@pytest.mark.skipif(
sys.version_info >= (3, 8),
reason="the copy function uses sendfile in Python 3.8+, "
"making the patched implementation irrelevant",
)
def test_copy_sendfile(self):
# try copying using sendfile
with mock.patch.object(osfs, "sendfile") as sendfile:
Expand Down

0 comments on commit 3e02968

Please sign in to comment.