Skip to content

Commit

Permalink
[libclang/python/tests] Remove unused variables (llvm#114397)
Browse files Browse the repository at this point in the history
Remove all occurrences of unused varialbes in the python bindings tests.
Use `_` to ignore unused values in tuple unpacking expressions.
  • Loading branch information
DeinAlptraum authored Oct 31, 2024
1 parent d0ffb53 commit 4493897
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions clang/bindings/python/tests/cindex/test_cdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_create_fail(self):
with open(os.devnull, "wb") as null:
os.dup2(null.fileno(), 2)
with self.assertRaises(CompilationDatabaseError) as cm:
cdb = CompilationDatabase.fromDirectory(path)
CompilationDatabase.fromDirectory(path)
os.dup2(stderr, 2)
os.close(stderr)

Expand All @@ -40,7 +40,7 @@ def test_create_fail(self):

def test_create(self):
"""Check we can load a compilation database"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)
CompilationDatabase.fromDirectory(kInputsDir)

def test_lookup_succeed(self):
"""Check we get some results if the file exists in the db"""
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_compilationDB_references(self):
cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
del cdb
gc.collect()
workingdir = cmds[0].directory
cmds[0].directory

def test_compilationCommands_references(self):
"""Ensure CompilationsCommand keeps a reference to CompilationCommands"""
Expand All @@ -185,4 +185,4 @@ def test_compilationCommands_references(self):
cmd0 = cmds[0]
del cmds
gc.collect()
workingdir = cmd0.directory
cmd0.directory
2 changes: 1 addition & 1 deletion clang/bindings/python/tests/cindex/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_references(self):
self.assertIsInstance(cursor.translation_unit, TranslationUnit)

# If the TU was destroyed, this should cause a segfault.
parent = cursor.semantic_parent
cursor.semantic_parent

def test_canonical(self):
source = "struct X; struct X; struct X { int member; };"
Expand Down
2 changes: 1 addition & 1 deletion clang/bindings/python/tests/cindex/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class TestIndex(unittest.TestCase):
def test_create(self):
index = Index.create()
Index.create()

# FIXME: test Index.read

Expand Down
6 changes: 3 additions & 3 deletions clang/bindings/python/tests/cindex/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_references(self):
self.assertIsInstance(t.translation_unit, TranslationUnit)

# If the TU was destroyed, this should cause a segfault.
decl = t.get_declaration()
t.get_declaration()

def testConstantArray(self):
tu = get_tu(constarrayInput)
Expand Down Expand Up @@ -459,8 +459,8 @@ def test_offset(self):
(["-target", "i386-pc-win32"], (8, 16, 0, 32, 64, 96)),
(["-target", "msp430-none-none"], (2, 14, 0, 32, 64, 96)),
]
for flags, values in tries:
align, total, f1, bariton, foo, bar = values
for _, values in tries:
_, _, f1, bariton, foo, bar = values
tu = get_tu(source)
teststruct = get_cursor(tu, "Test")
children = list(teststruct.get_children())
Expand Down

0 comments on commit 4493897

Please sign in to comment.