Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# ^PTR = nnn
assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)
# ^PTR = "filename"
assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)
# ^PTR = ("filename")
assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)
# ^PTR = ("filename", nnn)
# Example tests/mission_data/W1782844276_1.LBL
assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)
# ^PTR = ("filename", nnn )
assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)
# Test bad type
with pytest.raises(ValueError):
Pointer.parse(None, 64)
# Test wrong sized arrays
with pytest.raises(ValueError):
Pointer.parse([], 64)
with pytest.raises(ValueError):
Pointer.parse(['W1782844276_1.IMG', 5, 6], 64)
def test_parse_pointer():
# ^PTR = nnn
# Example tests/mission_data/1p432690858esfc847p2111l2m1.img
assert Pointer.parse(56, 640) == Pointer(None, 35200)
# ^PTR = nnn
assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)
# ^PTR = "filename"
assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)
# ^PTR = ("filename")
assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)
# ^PTR = ("filename", nnn)
# Example tests/mission_data/W1782844276_1.LBL
assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)
# ^PTR = ("filename", nnn )
assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)
# Test bad type
with pytest.raises(ValueError):
def _parse_bytes(value, record_bytes):
if isinstance(value, six.integer_types):
return (value - 1) * record_bytes
if isinstance(value, pvl.Units) and value.units == 'BYTES':
return value.value
raise ValueError('Unsupported pointer type')