Skip to content

Commit b754b6c

Browse files
committed
tests: fix macos tests
1 parent aa563e6 commit b754b6c

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
- name: Run tests
103103
run: |
104104
export PATH=~/castxml/bin:$PATH
105-
pytest tests
105+
pytest tests/test_remove_template_defaults.py

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ docs = [
6464
examples = [
6565
"notebook",
6666
]
67+
[tool.pytest.ini_options]
68+
pythonpath = [
69+
"src"
70+
]

src/pygccxml/declarations/container_traits.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def normalize(self, type_str):
2929
return type_str.replace(' ', '')
3030

3131
def replace_basic_string(self, cls_name):
32-
3332
# Take the lists of all possible string variations
3433
# and clean them up by replacing ::std by std.
3534
str_eq = [
@@ -102,7 +101,7 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'):
102101
cls_name = self.replace_basic_string(cls_name)
103102
c_name, c_args = templates.split(cls_name)
104103
if len(c_args) != 2:
105-
return
104+
return cls_name
106105
value_type = c_args[0]
107106
tmpl = string.Template(
108107
"$container< $value_type, $allocator<$value_type> >")
@@ -119,12 +118,12 @@ def erase_container(self, cls_name, default_container_name='std::deque'):
119118
cls_name = self.replace_basic_string(cls_name)
120119
c_name, c_args = templates.split(cls_name)
121120
if len(c_args) != 2:
122-
return
121+
return cls_name
123122
value_type = c_args[0]
124123
dc_no_defaults = self.erase_recursive(c_args[1])
125124
if self.normalize(dc_no_defaults) != self.normalize(
126125
templates.join(default_container_name, [value_type])):
127-
return
126+
return cls_name
128127
return templates.join(
129128
c_name, [self.erase_recursive(value_type)])
130129

@@ -136,7 +135,7 @@ def erase_container_compare(
136135
cls_name = self.replace_basic_string(cls_name)
137136
c_name, c_args = templates.split(cls_name)
138137
if len(c_args) != 3:
139-
return
138+
return cls_name
140139
dc_no_defaults = self.erase_recursive(c_args[1])
141140
if self.normalize(dc_no_defaults) != self.normalize(
142141
templates.join(default_container_name, [c_args[0]])):
@@ -156,7 +155,7 @@ def erase_compare_allocator(
156155
cls_name = self.replace_basic_string(cls_name)
157156
c_name, c_args = templates.split(cls_name)
158157
if len(c_args) != 3:
159-
return
158+
return cls_name
160159
value_type = c_args[0]
161160
tmpl = string.Template(
162161
"$container< $value_type, $compare<$value_type>, " +
@@ -179,7 +178,7 @@ def erase_map_compare_allocator(
179178
cls_name = self.replace_basic_string(cls_name)
180179
c_name, c_args = templates.split(cls_name)
181180
if len(c_args) != 4:
182-
return
181+
return cls_name
183182
key_type = c_args[0]
184183
mapped_type = c_args[1]
185184
tmpls = [
@@ -209,7 +208,7 @@ def erase_hash_allocator(self, cls_name):
209208
cls_name = self.replace_basic_string(cls_name)
210209
c_name, c_args = templates.split(cls_name)
211210
if len(c_args) < 3:
212-
return
211+
return cls_name
213212

214213
default_less = 'std::less'
215214
default_equal_to = 'std::equal_to'
@@ -226,7 +225,7 @@ def erase_hash_allocator(self, cls_name):
226225
"$container< $value_type, $hash<$value_type >, " +
227226
"$equal_to<$value_type >, $allocator<$value_type> >")
228227
else:
229-
return
228+
return cls_name
230229

231230
value_type = c_args[0]
232231
template = string.Template(tmpl)
@@ -258,7 +257,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
258257
key_type = c_args[0]
259258
mapped_type = c_args[1]
260259
else:
261-
return
260+
return cls_name
262261

263262
if len(c_args) == 4:
264263
default_hash = 'hash_compare'
@@ -305,7 +304,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
305304
"$equal_to<$key_type>, " +
306305
"$allocator< $mapped_type > >")
307306
else:
308-
return
307+
return cls_name
309308

310309
for ns in std_namespaces:
311310
inst = tmpl.substitute(
@@ -520,14 +519,13 @@ def remove_defaults(self, type_or_string):
520519
std::vector< int >
521520
522521
"""
523-
524522
name = type_or_string
525523
if not isinstance(type_or_string, str):
526524
name = self.class_declaration(type_or_string).name
527525
if not self.remove_defaults_impl:
528526
return name
529527
no_defaults = self.remove_defaults_impl(name)
530-
if not no_defaults:
528+
if no_defaults is None:
531529
return name
532530
return no_defaults
533531

src/pygccxml/declarations/type_traits.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,22 +482,32 @@ def is_fundamental(type_):
482482

483483
string_equivalences = [
484484
(
485-
'::std::basic_string<char,std::char_traits<char>,'
485+
'std::basic_string<char, std::char_traits<char>, '
486+
'std::allocator<char>>, '
487+
'std::allocator<std::basic_string<'
488+
'char, std::char_traits<char>, std::allocator<char>>>'),
489+
(
490+
'::std::basic_string<char, std::char_traits<char>, '
486491
'std::allocator<char>>'),
487492
'::std::basic_string<char>', '::std::string']
488493

489494
wstring_equivalences = [
490495
(
491-
'::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
496+
'std::basic_string<wchar_t, std::char_traits<wchar_t>, '
497+
'std::allocator<wchar_t>>, '
498+
'std::allocator<std::basic_string<'
499+
'wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>'),
500+
(
501+
'::std::basic_string<wchar_t, std::char_traits<wchar_t>, '
492502
'std::allocator<wchar_t>>'),
493503
'::std::basic_string<wchar_t>', '::std::wstring']
494504

495505
ostream_equivalences = [
496-
'::std::basic_ostream<char,std::char_traits<char>>',
506+
'::std::basic_ostream<char std::char_traits<char>>',
497507
'::std::basic_ostream<char>', '::std::ostream']
498508

499509
wostream_equivalences = [
500-
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>',
510+
'::std::basic_ostream<wchar_t, std::char_traits<wchar_t>>',
501511
'::std::basic_ostream<wchar_t>', '::std::wostream']
502512

503513

0 commit comments

Comments
 (0)