Changeset 1810:840277a08296


Ignore:
Timestamp:
Jun 17, 2019, 10:24:44 PM (2 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Remove `ascii_data`

This function is no longer needed. I assume this was used when we
still had an "ASCII" mode that was about converting line endings on
the fly.

Since `random_data` now would only be needed in `binary_data`, merge
`random_data` into `binary_data`.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/test_host.py

    r1809 r1810  
    3131
    3232#
    33 # Helper functions to generate random data
     33# Helper function to generate random data
    3434#
    35 def random_data(pool, size=10000):
     35def binary_data():
    3636    """
    37     Return a byte string of characters consisting of those from the
    38     pool of integer numbers.
     37    Return a bytes object of length 10000, consisting of bytes from a pool of
     38    integer numbers in the range 0..255.
    3939    """
    40     ordinal_list = [random.choice(pool) for i in range(size)]
    41     return bytes(ordinal_list)
    42 
    43 
    44 def ascii_data():
    45     r"""
    46     Return a unicode string of "normal" ASCII characters, including `\r`.
    47     """
    48     pool = list(range(32, 128))
    49     # The idea is to have the "\r" converted to "\n" during the later
    50     # text write and check this conversion.
    51     pool.append(ord("\r"))
    52     return ftputil.tool.as_unicode(random_data(pool))
    53 
    54 
    55 def binary_data():
    56     """Return a binary character byte string."""
    5740    pool = list(range(0, 256))
    58     return random_data(pool)
     41    size = 10000
     42    integer_list = [random.choice(pool) for i in range(size)]
     43    return bytes(integer_list)
    5944
    6045
Note: See TracChangeset for help on using the changeset viewer.