Skip to content

Commit 686f507

Browse files
committed
Use pathlib for input file paths
1 parent 74cf17d commit 686f507

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clang/bindings/python/tests/cindex/test_location.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23

34
from clang.cindex import (
45
Config,
@@ -16,7 +17,7 @@
1617

1718
from .util import get_cursor, get_tu
1819

19-
INPUTS_DIR = os.path.join(os.path.dirname(__file__), "INPUTS")
20+
INPUTS_DIR = Path(__file__).parent / "INPUTS"
2021

2122
BASE_INPUT = "int one;\nint two;\n"
2223

@@ -155,8 +156,8 @@ def test_operator_lt(self):
155156
assert not l_t1_14 < l_t2_13
156157

157158
def test_equality(self):
158-
path = os.path.join(INPUTS_DIR, "testfile.c")
159-
path_a = os.path.join(INPUTS_DIR, "a.inc")
159+
path = INPUTS_DIR / "testfile.c"
160+
path_a = INPUTS_DIR / "a.inc"
160161
tu = TranslationUnit.from_source(path)
161162
main_file = File.from_name(tu, path)
162163
a_file = File.from_name(tu, path_a)

clang/bindings/python/tests/cindex/test_source_range.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from pathlib import Path
23

34
from clang.cindex import Config, SourceLocation, SourceRange, TranslationUnit
45

@@ -9,7 +10,7 @@
910

1011
from .util import get_tu
1112

12-
INPUTS_DIR = os.path.join(os.path.dirname(__file__), "INPUTS")
13+
INPUTS_DIR = Path(__file__).parent / "INPUTS"
1314

1415

1516
def create_range(tu, line1, column1, line2, column2):
@@ -87,7 +88,7 @@ def test_contains(self):
8788
assert l_f2 in r_curly
8889

8990
def test_equality(self):
90-
path = os.path.join(INPUTS_DIR, "testfile.c")
91+
path = INPUTS_DIR / "testfile.c"
9192
tu = TranslationUnit.from_source(path)
9293

9394
r1 = create_range(tu, 1, 1, 2, 2)

0 commit comments

Comments
 (0)