Skip to content

Commit f6bab5a

Browse files
committed
tests: resolve __file__ to be abs path
1 parent 1561476 commit f6bab5a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tests/runtests.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import glob
22
import os
33
import subprocess
4+
from pathlib import Path
45

56
# Change work dir if not in tests/
6-
tests_dir = os.path.dirname(__file__)
7-
if os.getcwd() != tests_dir:
7+
tests_dir = Path(__file__).parent.resolve()
8+
if Path.cwd() != tests_dir:
89
os.chdir(tests_dir)
910

1011
tests = sorted(glob.glob("[A-Za-z]*.py"))
1112
excludes = ["runtests.py"]
1213

13-
output_dir = os.path.join(os.path.dirname(__file__), "output")
14-
if not os.path.exists(output_dir):
14+
output_dir = tests_dir / "output"
15+
if not output_dir.exists():
1516
os.mkdir(output_dir)
1617

1718
for test in tests:

0 commit comments

Comments
 (0)