Skip to content

Commit 5b84129

Browse files
committed
Make test case more portable
1 parent 72e8cd8 commit 5b84129

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
TEST_DIR = Path(__file__).resolve().parent
16+
CTYPESGEN_DIR = TEST_DIR.parent
1617
COMMON_DIR = TEST_DIR/"common"
1718
TMP_DIR = TEST_DIR/"tmp"
1819

tests/testsuite.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import math
3030
import unittest
3131
import subprocess
32+
from pathlib import Path
3233
from contextlib import (
3334
redirect_stdout,
3435
redirect_stderr,
@@ -44,6 +45,7 @@
4445
ctypesgen_wrapper,
4546
module_from_code,
4647
TMP_DIR,
48+
CTYPESGEN_DIR,
4749
CLEANUP_OK,
4850
)
4951
from . import json_expects
@@ -1064,14 +1066,15 @@ def tearDownClass(cls):
10641066
cls.outpath.unlink()
10651067

10661068
def test_content(self):
1069+
# FIXME the double backslash is actually wrong -- maybe we should remove the R-string prefix, as python seems to auto-escape as necessary
10671070
exp_docstring = R"""
10681071
Auto-generated by:
10691072
ctypesgen.api_main(
10701073
{'library': 'c',
1071-
'output': PosixPath('./tests/tmp/apimain_stdio.py'),
1074+
'output': %s,
10721075
'symbol_rules': ['if_needed=__\\w+'],
10731076
'system_headers': ['stdio.h']}
10741077
)
1075-
"""
1078+
""" % (repr(self.outpath).replace(str(CTYPESGEN_DIR), "."), )
10761079
self.assertEqual(self.module.__doc__, exp_docstring)
10771080
self.assertTrue(hasattr(self.module, "printf"))

0 commit comments

Comments
 (0)