Esempio n. 1
0
def test_comparision():
    a = UUID(int=10)
    b = UUID(int=20)
    c = UUID(int=20)

    assert a < b
    assert b > a
    assert a <= b
    assert b >= a
    assert c <= c
    assert c >= c
Esempio n. 2
0
def test_uuid_without_arguments():
    with pytest.raises(
            TypeError,
            match=
            "one of the hex, bytes, bytes_le, fields, or int arguments must be given"
    ):
        UUID()
Esempio n. 3
0
def test_equality():
    expected = uuid4()
    actual = UUID(str(expected))
    other = uuid4()

    assert expected == actual
    assert expected != other
Esempio n. 4
0
def test_time_hi_version_property(u):
    expected = u.time_hi_version
    actual = UUID(str(u)).time_hi_version

    assert expected == actual
Esempio n. 5
0
def test_fields_property(u):
    expected = u.fields
    actual = UUID(str(u)).fields

    assert expected == actual
Esempio n. 6
0
def test_fields_time_low_out_of_range(fields):
    with pytest.raises(ValueError,
                       match=r"field 1 out of range \(need a 32-bit value\)"):
        UUID(fields=fields)
Esempio n. 7
0
def test_bad_version(expected, bad_version):
    with pytest.raises(ValueError, match="illegal version number"):
        UUID(str(expected), version=bad_version)
Esempio n. 8
0
def test_hex_bad_string(bad_hex):
    with pytest.raises(ValueError,
                       match="badly formed hexadecimal UUID string"):
        UUID(bad_hex)
Esempio n. 9
0
def test_time_property(u):
    expected = u.time
    actual = UUID(str(u)).time

    assert expected == actual
Esempio n. 10
0
def test_fields(expected):
    assert str(UUID(fields=expected.fields)) == str(expected)
Esempio n. 11
0
def test_bytes_le(expected):
    assert str(UUID(bytes_le=expected.bytes_le)) == str(expected)
Esempio n. 12
0
def test_bytes(expected):
    assert str(UUID(bytes=expected.bytes)) == str(expected)
Esempio n. 13
0
def test_int(expected):
    actual = UUID(int=expected.int)
    assert str(actual) == str(expected)
    assert int(actual) == int(expected)
Esempio n. 14
0
def test_fields_node_out_of_range(fields):
    with pytest.raises(ValueError,
                       match=r"field 6 out of range \(need a 48-bit value\)"):
        UUID(fields=fields)
Esempio n. 15
0
def test_clock_seq_hi_variant_property(u):
    expected = u.clock_seq_hi_variant
    actual = UUID(str(u)).clock_seq_hi_variant

    assert expected == actual
Esempio n. 16
0
def test_int_property(u):
    expected = u.int
    actual = UUID(str(u)).int

    assert expected == actual
Esempio n. 17
0
def test_clock_seq_low_property(u):
    expected = u.clock_seq_low
    actual = UUID(str(u)).clock_seq_low

    assert expected == actual
Esempio n. 18
0
def test_hex_property(u):
    expected = u.hex
    actual = UUID(str(u)).hex

    assert expected == actual
Esempio n. 19
0
def test_node_property(u):
    expected = u.node
    actual = UUID(str(u)).node

    assert expected == actual
Esempio n. 20
0
def test_urn_property(u):
    expected = u.urn
    actual = UUID(str(u)).urn

    assert expected == actual
Esempio n. 21
0
def test_bad_bytes_le(bad_bytes):
    with pytest.raises(ValueError, match="bytes_le is not a 16-char string"):
        UUID(bytes_le=bad_bytes)
Esempio n. 22
0
def test_bytes_le_property(u):
    expected = u.bytes_le
    actual = UUID(str(u)).bytes_le

    assert expected == actual
Esempio n. 23
0
def test_wrong_fields_count(fields):
    fields = tuple(fields)
    with pytest.raises(ValueError, match="fields is not a 6-tuple"):
        UUID(fields=fields)
Esempio n. 24
0
def test_hex(expected):
    expected = str(expected)

    assert str(UUID(hex=expected)) == expected
Esempio n. 25
0
def test_fields_time_high_version_out_of_range(fields):
    with pytest.raises(ValueError,
                       match=r"field 3 out of range \(need a 16-bit value\)"):
        UUID(fields=fields)
Esempio n. 26
0
def test_fields_clock_seq_low_out_of_range(fields):
    with pytest.raises(ValueError,
                       match=r"field 5 out of range \(need a 8-bit value\)"):
        UUID(fields=fields)