Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 552b307

Browse files
committed
chore: add SingleConstraintAssertion overloads
1 parent e60cd28 commit 552b307

File tree

3 files changed

+363
-11
lines changed

3 files changed

+363
-11
lines changed

tests/test_constraint_streams.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ def define_constraints(constraint_factory: ConstraintFactory):
721721

722722

723723
def test_has_all_methods():
724+
missing = []
724725
for python_type, java_type in ((UniConstraintStream, JavaUniConstraintStream),
725726
(BiConstraintStream, JavaBiConstraintStream),
726727
(TriConstraintStream, JavaTriConstraintStream),
@@ -732,7 +733,6 @@ def test_has_all_methods():
732733
(Joiners, JavaJoiners),
733734
(ConstraintCollectors, JavaConstraintCollectors),
734735
(ConstraintFactory, JavaConstraintFactory)):
735-
missing = []
736736
for function_name, function_impl in inspect.getmembers(java_type, inspect.isfunction):
737737
if function_name in ignored_java_functions:
738738
continue
@@ -745,8 +745,10 @@ def test_has_all_methods():
745745
# change h_t_t_p -> http
746746
snake_case_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', snake_case_name).lower()
747747
if not hasattr(python_type, snake_case_name):
748-
missing.append(snake_case_name)
748+
missing.append((java_type, python_type, snake_case_name))
749749

750-
if missing:
751-
raise AssertionError(f'{python_type} is missing methods ({missing}) '
752-
f'from java_type ({java_type}).)')
750+
if missing:
751+
assertion_msg = ''
752+
for java_type, python_type, snake_case_name in missing:
753+
assertion_msg += f'{python_type} is missing a method ({snake_case_name}) from java_type ({java_type}).)\n'
754+
raise AssertionError(assertion_msg)

tests/test_constraint_verifier.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,27 +285,29 @@ class Solution:
285285
'notifyAll',
286286
'toString',
287287
'wait',
288-
'with_constraint_stream_impl_type'
288+
'withConstraintStreamImplType'
289289
}
290290

291291

292292
def test_has_all_methods():
293+
missing = []
293294
for python_type, java_type in ((ConstraintVerifier, JavaConstraintVerifier),
294295
(SingleConstraintAssertion, JavaSingleConstraintAssertion),
295296
(SingleConstraintVerification, JavaSingleConstraintVerification),
296297
(MultiConstraintAssertion, JavaMultiConstraintAssertion),
297298
(MultiConstraintVerification, JavaMultiConstraintVerification)):
298-
missing = []
299299
for function_name, function_impl in inspect.getmembers(java_type, inspect.isfunction):
300300
if function_name in ignored_java_functions:
301301
continue
302302
snake_case_name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', function_name)
303303
# change h_t_t_p -> http
304304
snake_case_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', snake_case_name).lower()
305305
if not hasattr(python_type, snake_case_name):
306-
missing.append(snake_case_name)
306+
missing.append((java_type, python_type, snake_case_name))
307307

308308
if missing:
309-
raise AssertionError(f'{python_type} is missing methods ({missing}) '
310-
f'from java_type ({java_type}).)')
309+
assertion_msg = ''
310+
for java_type, python_type, snake_case_name in missing:
311+
assertion_msg += f'{python_type} is missing a method ({snake_case_name}) from java_type ({java_type}).)\n'
312+
raise AssertionError(assertion_msg)
311313

0 commit comments

Comments
 (0)