コード例 #1
0
    def test_bytes_suffix_is_valid(self):
        s = "7B"

        actual = Memory.from_str(s)
        expected = Memory(7)

        assert actual == expected
コード例 #2
0
    def test_suffix_is_case_insensitive(self):
        s = "500zb"

        actual = Memory.from_str(s).bytes()
        expected = Memory(500, Unit.ZETTA).bytes()

        assert actual == expected
コード例 #3
0
    def test_multiple_spaces_between_size_and_suffix_is_valid(self):
        s = "500  MB"

        actual = Memory.from_str(s)
        expected = Memory(500, Unit.MEGA)

        assert actual == expected
コード例 #4
0
    def test_b_suffix_is_valid(self):
        s = "500MB"

        actual = Memory.from_str(s)
        expected = Memory(500, Unit.MEGA)

        assert actual == expected
コード例 #5
0
    def test_no_suffix_and_float_returns_bytes(self):
        s = "500.8"

        actual = Memory.from_str(s)
        expected = Memory(500.8)

        assert actual == expected
コード例 #6
0
    def test_no_suffix_returns_bytes(self):
        s = "500"

        actual = Memory.from_str(s)
        expected = Memory(500)

        assert actual == expected
コード例 #7
0
    def test_string_with_other_characters_raises_error(self):
        s = "7KBY"

        with pytest.raises(InvalidMemoryString):
            Memory.from_str(s)
コード例 #8
0
    def test_invalid_suffix_raises_error(self):
        s = "7LB"

        with pytest.raises(InvalidMemoryString):
            Memory.from_str(s)
コード例 #9
0
    def test_suffix_only_raises_error(self):
        s = "TB"

        with pytest.raises(InvalidMemoryString):
            Memory.from_str(s)
コード例 #10
0
    def test_empty_string_raises_error(self):
        s = ""

        with pytest.raises(InvalidMemoryString):
            Memory.from_str(s)