Skip to content

Commit 8165577

Browse files
committed
tests: fix macos tests
Fix string replacement (broken due to space mismatches)
1 parent 682dc7e commit 8165577

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ examples = [
6565
"notebook",
6666
]
6767
[tool.pytest.ini_options]
68-
pythonpath = [
69-
"src"]
68+
pythonpath = [
69+
"src"
70+
]

src/pygccxml/declarations/container_traits.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919

2020
std_namespaces = ('std', 'stdext', '__gnu_cxx')
2121

22+
# Take into account different equivalences (with or without spaces)
23+
string_equivalences = type_traits.string_equivalences + \
24+
type_traits.normalized_string_equivalences
25+
string_equivalences = [
26+
v for v in string_equivalences if not v == "std::string"]
27+
wstring_equivalences = type_traits.wstring_equivalences + \
28+
type_traits.normalized_wstring_equivalences
29+
wstring_equivalences = [
30+
v for v in wstring_equivalences if not v == "std::wstring"]
31+
2232

2333
class defaults_eraser(object):
2434

@@ -29,16 +39,9 @@ def normalize(self, type_str):
2939
return type_str.replace(' ', '')
3040

3141
def replace_basic_string(self, cls_name):
32-
# Replace all the variations of strings by the smallest one.
3342
strings = {
34-
"std::string":
35-
[v for v in
36-
type_traits.normalized_string_equivalences
37-
if not v == "std::string"],
38-
"std::wstring":
39-
[v for v in
40-
type_traits.normalized_wstring_equivalences
41-
if not v == "std::wstring"]
43+
"std::string": string_equivalences,
44+
"std::wstring": wstring_equivalences
4245
}
4346

4447
new_name = cls_name

src/pygccxml/declarations/type_traits.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def is_fundamental(type_):
481481

482482

483483
def _normalize(string):
484-
return string.replace(' ', '').replace("::std", "std")
484+
return string.replace(' ', '').replace('::std', 'std')
485485

486486

487487
def _normalize_equivalences(equivalences):
@@ -490,29 +490,33 @@ def _normalize_equivalences(equivalences):
490490

491491
string_equivalences = [
492492
(
493-
'::std::basic_string<char, std::char_traits<char>, '
493+
'std::basic_string<char, std::char_traits<char>, '
494494
'std::allocator<char>>'
495495
),
496-
'::std::basic_string<char>',
497-
'::std::string'
496+
'std::basic_string<char>',
497+
'std::string'
498498
]
499499

500500
wstring_equivalences = [
501501
(
502-
'::std::basic_string<wchar_t, std::char_traits<wchar_t>, '
502+
'std::basic_string<wchar_t, std::char_traits<wchar_t>, '
503503
'std::allocator<wchar_t>>'
504504
),
505-
'::std::basic_string<wchar_t>',
506-
'::std::wstring'
505+
'std::basic_string<wchar_t>',
506+
'std::wstring'
507507
]
508508

509509
ostream_equivalences = [
510-
'::std::basic_ostream<char, std::char_traits<char>>',
511-
'::std::basic_ostream<char>', '::std::ostream']
510+
'std::basic_ostream<char, std::char_traits<char>>',
511+
'std::basic_ostream<char>',
512+
'std::ostream'
513+
]
512514

513515
wostream_equivalences = [
514-
'::std::basic_ostream<wchar_t, std::char_traits<wchar_t>>',
515-
'::std::basic_ostream<wchar_t>', '::std::wostream']
516+
'std::basic_ostream<wchar_t, std::char_traits<wchar_t>>',
517+
'std::basic_ostream<wchar_t>',
518+
'std::wostream'
519+
]
516520

517521

518522
normalized_string_equivalences = _normalize_equivalences(
@@ -541,6 +545,7 @@ def is_std_string(type_):
541545
type_ = remove_alias(type_)
542546
type_ = remove_reference(type_)
543547
type_ = remove_cv(type_)
548+
544549
return _normalize(type_.decl_string) in normalized_string_equivalences
545550

546551

0 commit comments

Comments
 (0)