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_elf_find_ucs2_symbols(self):
# GIVEN
elf = Mock()
asunicode = MockSymbol("PyUnicodeUCS2_AsUnicode",
st_shndx="SHN_UNDEF",
st_info=dict(type="STT_FUNC"))
symbols = (asunicode, Mock())
symbols[1].name = "foobar"
elf.get_section_by_name.return_value.iter_symbols.return_value = symbols
# WHEN
symbols = list(elf_find_ucs2_symbols(elf))
# THEN
assert len(symbols) == 1
assert symbols[0] == 'PyUnicodeUCS2_AsUnicode'
def test_elf_find_ucs2_symbols_no_symbol(self):
# GIVEN
elf = Mock()
symbols = (MockSymbol("FooSymbol"),)
elf.get_section_by_name.return_value.iter_symbols.return_value = symbols
# WHEN/THEN
symbols = list(elf_find_ucs2_symbols(elf))
assert len(symbols) == 0
elftree = lddtree(fn)
for key, value in elf_find_versioned_symbols(elf):
log.debug('key %s, value %s', key, value)
versioned_symbols[key].add(value)
is_py_ext, py_ver = elf_is_python_extension(fn, elf)
# If the ELF is a Python extention, we definitely need to
# include its external dependencies.
if is_py_ext:
full_elftree[fn] = elftree
uses_PyFPE_jbuf |= elf_references_PyFPE_jbuf(elf)
if py_ver == 2:
uses_ucs2_symbols |= any(
True for _ in elf_find_ucs2_symbols(elf))
full_external_refs[fn] = lddtree_external_references(
elftree,
ctx.path)
else:
# If the ELF is not a Python extension, it might be
# included in the wheel already because auditwheel repair
# vendored it, so we will check whether we should include
# its internal references later.
nonpy_elftree[fn] = elftree
if not platform_wheel:
raise NonPlatformWheel
# If at least one shared library exists in purelib, raise an error
if shared_libraries_in_purelib:
raise RuntimeError(