Changeset 1834:1fd91d46a098


Ignore:
Timestamp:
Jul 10, 2019, 11:22:23 PM (5 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use `ScriptedSession` in `TestParsers`
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_stat.py

    r1723 r1834  
    1 # Copyright (C) 2003-2018, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2003-2019, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# and ftputil contributors (see `doc/contributors.txt`)
    33# See the file LICENSE for licensing terms.
     
    1515from test import test_base
    1616from test import mock_ftplib
     17from test import scripted_session
     18
     19
     20Call = scripted_session.Call
    1721
    1822
     
    316320        to full hours.
    317321        """
    318         host = test_base.ftp_host_factory()
    319         # Explicitly use Unix format parser here.
    320         host._stat._parser = ftputil.stat.UnixParser()
    321         host.set_time_shift(supposed_time_shift)
    322         server_time = time.time() + supposed_time_shift + deviation
    323         stat_result = host._stat._parser.parse_line(self.dir_line(server_time),
    324                                                     host.time_shift())
    325         self.assert_equal_times(stat_result.st_mtime, server_time)
     322        script = [
     323          Call("__init__"),
     324          Call("pwd", result="/"),
     325          Call("close")
     326        ]
     327        with test_base.ftp_host_factory(scripted_session.factory(script)) as host:
     328            host.stat_cache.disable()
     329            # Explicitly use Unix format parser here.
     330            host._stat._parser = ftputil.stat.UnixParser()
     331            host.set_time_shift(supposed_time_shift)
     332            server_time = time.time() + supposed_time_shift + deviation
     333            stat_result = host._stat._parser.parse_line(self.dir_line(server_time),
     334                                                        host.time_shift())
     335            self.assert_equal_times(stat_result.st_mtime, server_time)
    326336
    327337    def test_time_shifts(self):
Note: See TracChangeset for help on using the changeset viewer.