Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestFtpStoreDataTLSMixin.test_rest_on_stor and TestFtpStoreDataTLSMixin.test_stor_ascii fail #512

Closed
sbraz opened this issue Nov 26, 2019 · 3 comments

Comments

@sbraz
Copy link
Contributor

sbraz commented Nov 26, 2019

Hi,
I don't know what triggers this but those tests don't pass any more on my systems (Gentoo and Arch tested).

Here is the original bug report: https://bugs.gentoo.org/701146

I can reproduce it with the master branch with PYTHONPATH=. pytest -vv pyftpdlib/test/test_functional_ssl.py::TestFtpStoreDataTLSMixin::test_rest_on_stor pyftpdlib/test/test_functional_ssl.py::TestFtpStoreDataTLSMixin::test_stor_ascii:

============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-4.6.6, py-1.8.0, pluggy-0.13.0 -- /usr/bin/python3.6
cachedir: .pytest_cache
rootdir: /tmp/pyftpdlib
plugins: backports.unittest-mock-1.5
collecting ... collected 2 items

pyftpdlib/test/test_functional_ssl.py::TestFtpStoreDataTLSMixin::test_rest_on_stor <- pyftpdlib/test/test_functional.py FAILED [ 50%]
pyftpdlib/test/test_functional_ssl.py::TestFtpStoreDataTLSMixin::test_stor_ascii <- pyftpdlib/test/test_functional.py FAILED [100%]

=================================== FAILURES ===================================
__________________ TestFtpStoreDataTLSMixin.test_rest_on_stor __________________

self = <pyftpdlib.test.test_functional_ssl.TestFtpStoreDataTLSMixin testMethod=test_rest_on_stor>

    def test_rest_on_stor(self):
        # Test STOR preceded by REST.
        data = b'abcde12345' * 100000
        self.dummy_sendfile.write(data)
        self.dummy_sendfile.seek(0)
    
        self.client.voidcmd('TYPE I')
        with contextlib.closing(
                self.client.transfercmd('stor ' + TESTFN)) as conn:
            bytes_sent = 0
            while True:
                chunk = self.dummy_sendfile.read(BUFSIZE)
                conn.sendall(chunk)
                bytes_sent += len(chunk)
                # stop transfer while it isn't finished yet
                if bytes_sent >= INTERRUPTED_TRANSF_SIZE or not chunk:
                    break
    
        # transfer wasn't finished yet but server can't know this,
        # hence expect a 226 response
        self.assertEqual('226', self.client.voidresp()[:3])
    
        # resuming transfer by using a marker value greater than the
        # file size stored on the server should result in an error
        # on stor
        file_size = self.client.size(TESTFN)
>       self.assertEqual(file_size, bytes_sent)
E       AssertionError: 12288 != 32768

pyftpdlib/test/test_functional.py:898: AssertionError
___________________ TestFtpStoreDataTLSMixin.test_stor_ascii ___________________

self = <pyftpdlib.test.test_functional_ssl.TestFtpStoreDataTLSMixin testMethod=test_stor_ascii>

    def test_stor_ascii(self):
        # Test STOR in ASCII mode
    
        def store(cmd, fp, blocksize=8192):
            # like storbinary() except it sends "type a" instead of
            # "type i" before starting the transfer
            self.client.voidcmd('type a')
            with contextlib.closing(self.client.transfercmd(cmd)) as conn:
                while True:
                    buf = fp.read(blocksize)
                    if not buf:
                        break
                    conn.sendall(buf)
            return self.client.voidresp()
    
        try:
            data = b'abcde12345\r\n' * 100000
            self.dummy_sendfile.write(data)
            self.dummy_sendfile.seek(0)
            store('stor ' + TESTFN, self.dummy_sendfile)
            self.client.retrbinary('retr ' + TESTFN, self.dummy_recvfile.write)
            expected = data.replace(b'\r\n', b(os.linesep))
            self.dummy_recvfile.seek(0)
            datafile = self.dummy_recvfile.read()
>           self.assertEqual(len(expected), len(datafile))
E           AssertionError: 1100000 != 1073835

pyftpdlib/test/test_functional.py:720: AssertionError
=========================== 2 failed in 0.20 seconds ===========================
@giampaolo
Copy link
Owner

Those tests have been unstable for years and am not sure how to fix them. :-\

@DerDakon
Copy link

Dupe of #500 I guess.

@sbraz
Copy link
Contributor Author

sbraz commented Nov 28, 2019

Dupe of #500 I guess.

Absolutely, and yet a search for TestFtpStoreDataTLSMixin.test_rest_on_stor doesn't return it, weird.

@sbraz sbraz closed this as completed Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants