Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_rrsl_component_not_equal_bad_type():
com = pycdlib.rockridge.RRSLRecord.Component(0x0, 0, b'')
assert(com.__eq__(True) == NotImplemented)
def test_rrsl_component_name_dot():
com = pycdlib.rockridge.RRSLRecord.Component(0x02, 0, b'')
assert(com.name() == b'.')
def test_rrsl_component_not_equal():
com = pycdlib.rockridge.RRSLRecord.Component(0x0, 0, b'')
com2 = pycdlib.rockridge.RRSLRecord.Component(0x1, 0, b'')
assert(com != com2)
def test_rrsl_component_record_dotdot():
com = pycdlib.rockridge.RRSLRecord.Component(0x04, 0, b'')
assert(com.record() == b'\x04\x00')
def test_rrsl_component_record_root():
com = pycdlib.rockridge.RRSLRecord.Component(0x08, 0, b'')
assert(com.record() == b'\x08\x00')
def test_rrsl_component_record_dot():
com = pycdlib.rockridge.RRSLRecord.Component(0x02, 0, b'')
assert(com.record() == b'\x02\x00')
def test_rrsl_component_is_continued():
com = pycdlib.rockridge.RRSLRecord.Component(0x01, 0, b'')
assert(com.is_continued())
def __eq__(self, other):
# type: (object) -> bool
if not isinstance(other, RRSLRecord.Component):
return NotImplemented
return self.flags == other.flags and self.curr_length == other.curr_length and self.data == other.data
self.flags) = struct.unpack_from('=BBB', rrstr[:5], 2)
# We assume that the caller has already checked the su_entry_version,
# so we don't bother.
cr_offset = 5
data_len = su_len - 5
while data_len > 0:
(cr_flags, len_cp) = struct.unpack_from('=BB',
rrstr[:cr_offset + 2],
cr_offset)
data_len -= 2
cr_offset += 2
self.symlink_components.append(self.Component(cr_flags, len_cp,
rrstr[cr_offset:cr_offset + len_cp]))
# FIXME: if this is the last component in this SL record,
# but the component continues on in the next SL record, we will
# fail to record this bit. We should fix that.
cr_offset += len_cp
data_len -= len_cp
self._initialized = True