Skip to content

Commit 923dad9

Browse files
committed
Test that no new connection is opened with _manage_ftp in FTPFS.upload
1 parent 72e2fc9 commit 923dad9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_ftpfs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import unittest
1313
import uuid
1414

15-
from six import text_type
15+
try:
16+
from unittest import mock
17+
except ImportError:
18+
import mock
19+
20+
from six import text_type, BytesIO
1621

1722
from ftplib import error_perm
1823
from ftplib import error_temp
@@ -275,6 +280,12 @@ def test_create(self):
275280
with open_fs(url, create=True) as ftp_fs:
276281
self.assertTrue(ftp_fs.isfile("foo"))
277282

283+
def test_upload_connection(self):
284+
with mock.patch.object(self.fs, "_manage_ftp") as _manage_ftp:
285+
self.fs.upload("foo", BytesIO(b"hello"))
286+
self.assertEqual(self.fs.gettext("foo"), "hello")
287+
_manage_ftp.assert_not_called()
288+
278289

279290
class TestFTPFSNoMLSD(TestFTPFS):
280291
def make_fs(self):

0 commit comments

Comments
 (0)