Beispiel #1
0
def test_human_readable_bytes(args, kwargs, expected):
    """
    Test the `human_readable_bytes` function.

    Arguments:
        args: Positional arguments passed to the function.
        kwargs: Keyword arguments passed to the function.
        expected: The expected result.
    """
    assert human_readable_bytes(*args, **kwargs) == expected
    def verified_length_string(self, human_readable: bool = True) -> str:
        """
        Return the verified length as string.

        Arguments:
            human_readable: Return in human readable format or not.

        Returns:
            The verified length string.
        """
        if human_readable:
            return human_readable_bytes(self.verified_length, delim=" ")
        return str(self.verified_length) + " B"
    def upload_speed_string(self, human_readable: bool = True) -> str:
        """
        Return the upload speed as string.

        Arguments:
            human_readable: Return in human readable format or not.

        Returns:
            The upload speed string.
        """
        if human_readable:
            return human_readable_bytes(self.upload_speed, delim=" ", postfix="/s")
        return str(self.upload_speed) + " B/s"
Beispiel #4
0
def test_human_readable_bytes_0_digits():
    assert human_readable_bytes(0, digits=0) == "0B"
Beispiel #5
0
def test_human_readable_bytes():
    assert human_readable_bytes(0) == "0.00B"
Beispiel #6
0
def test_human_readable_tera_bytes():
    assert human_readable_bytes(2048 * 1024 * 1024 * 1024) == "2.00TiB"
Beispiel #7
0
def test_human_readable_giga_bytes():
    assert human_readable_bytes(2048 * 1024 * 1024) == "2.00GiB"
Beispiel #8
0
def test_human_readable_mebi_bytes():
    assert human_readable_bytes(2048 * 1024) == "2.00MiB"
Beispiel #9
0
def test_human_readable_kibi_bytes():
    assert human_readable_bytes(2048) == "2.00KiB"
Beispiel #10
0
def test_human_readable_bytes_all_kwargs():
    assert human_readable_bytes(1024, digits=0, delim=" ", postfix="/s") == "1 KiB/s"
Beispiel #11
0
def test_human_readable_bytes_with_postfix():
    assert human_readable_bytes(0, digits=0, delim=" ", postfix="/s") == "0 B/s"
Beispiel #12
0
def test_human_readable_bytes_space_delim():
    assert human_readable_bytes(0, digits=0, delim=" ") == "0 B"