Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.tox
__pycache__
.coverage*
htmlcov*
coverage*.xml
.pytest_cache
.tox
*.egg-info
*.pyc
coverage*.xml
htmlcov*
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ TODO
Version History
===============

1.3.1 - unreleased
------------------

- Fix ``is_dir`` under Python 3 no longer returning ``True`` for files with binary content. (#23, thanks @icemac)


1.3.0 - 2019-09-16
------------------
- Updated supported Python versions to 2.7, 3.5 - 3.7.
Expand Down
2 changes: 1 addition & 1 deletion pytest_sftpserver/sftp/content_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def list(self, path):
return [n for n in dir(obj) if not n.startswith("__")]

def is_dir(self, path):
return not isinstance(self.get(path), string_types + integer_types)
return not isinstance(self.get(path), (binary_type,) + string_types + integer_types)

def get_size(self, path):
try:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
black==19.3b0;python_version>="3.6"
click==8.0.4;python_version>="3.6"
flake8==3.7.8
flake8-bugbear==19.8.0;python_version>="3.5"
flake8-tuple==0.4.0
Expand Down
4 changes: 3 additions & 1 deletion tests/test_content_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
f=["testfile5", "testfile6"]
),
d="testfile3",
g=b"testfile7",
o=_TestObj(),
)
# fmt: on
Expand Down Expand Up @@ -107,7 +108,7 @@ def test_remove_obj_fail(content_provider):


def test_list_root(content_provider):
assert set(content_provider.list("/")) == set(["a", "d", "o"])
assert set(content_provider.list("/")) == set(["a", "d", "g", "o"])


def test_list_sub(content_provider):
Expand All @@ -120,6 +121,7 @@ def test_is_dir(content_provider):
assert content_provider.is_dir("/a")
assert content_provider.is_dir("/a/f")
assert content_provider.is_dir("/o")
assert not content_provider.is_dir("/g")
assert not content_provider.is_dir("/d")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# fmt: on


@pytest.yield_fixture(scope="session")
@pytest.fixture(scope="session")
def sftpclient(sftpserver):
transport = Transport((sftpserver.host, sftpserver.port))
transport.connect(username="a", password="b")
Expand All @@ -30,7 +30,7 @@ def sftpclient(sftpserver):
transport.close()


@pytest.yield_fixture
@pytest.fixture
def content(sftpserver):
with sftpserver.serve_content(deepcopy(CONTENT_OBJ)):
yield
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps =
paramiko

commands =
coverage run --source tests,pytest_sftpserver --branch --parallel -m py.test []
coverage run --source tests,pytest_sftpserver --branch --parallel -m pytest []

[testenv:cov-report]
deps =
Expand Down