@@ -49,7 +49,8 @@ def _collection_subject_new(
4949 meta ,
5050 container_name = "values" ,
5151 sortable = True ,
52- element_plural_name = "elements" ):
52+ element_plural_name = "elements" ,
53+ format = False ):
5354 """Creates a "CollectionSubject" struct.
5455
5556 Method: CollectionSubject.new
@@ -63,6 +64,7 @@ def _collection_subject_new(
6364 container_name: ([`str`]) conceptual name of the container.
6465 sortable: ([`bool`]) True if output should be sorted for display, False if not.
6566 element_plural_name: ([`str`]) the plural word for the values in the container.
67+ format: ([`bool`]) True if asserted values should be formatted.
6668
6769 Returns:
6870 [`CollectionSubject`].
@@ -94,6 +96,7 @@ def _collection_subject_new(
9496 sortable = sortable ,
9597 contains_predicate = public .contains_predicate ,
9698 contains_at_least_predicates = public .contains_at_least_predicates ,
99+ format = format ,
97100 )
98101 return public
99102
@@ -120,6 +123,8 @@ def _collection_subject_contains(self, expected):
120123 self: implicitly added.
121124 expected: ([`str`]) the value that must be present.
122125 """
126+ if self .format :
127+ expected = self .meta .format_str (expected )
123128 matcher = matching .equals_wrapper (expected )
124129 return self .contains_predicate (matcher )
125130
@@ -145,6 +150,8 @@ def _collection_subject_contains_exactly(self, expected):
145150 [`Ordered`] (see `_ordered_incorrectly_new`).
146151 """
147152 expected = to_list (expected )
153+ if self .format :
154+ expected = [self .meta .format_str (v ) for v in expected ]
148155 return check_contains_exactly (
149156 actual_container = self .actual ,
150157 expect_contains = expected ,
@@ -234,6 +241,8 @@ def _collection_subject_contains_none_of(self, values):
234241 self: implicitly added
235242 values: ([`collection`]) values of which none of are allowed to exist.
236243 """
244+ if self .format :
245+ values = self .meta .format_str (values )
237246 check_contains_none_of (
238247 collection = self .actual ,
239248 none_of = values ,
@@ -262,7 +271,7 @@ def _collection_subject_contains_predicate(self, matcher):
262271 meta = self .meta ,
263272 )
264273
265- def _collection_subject_contains_at_least (self , expect_contains ):
274+ def _collection_subject_contains_at_least (self , expected ):
266275 """Assert that the collection is a subset of the given predicates.
267276
268277 Method: CollectionSubject.contains_at_least
@@ -274,14 +283,17 @@ def _collection_subject_contains_at_least(self, expect_contains):
274283
275284 Args:
276285 self: implicitly added.
277- expect_contains : ([`list`]) values that must be in the collection.
286+ expected : ([`list`]) values that must be in the collection.
278287
279288 Returns:
280289 [`Ordered`] (see `_ordered_incorrectly_new`).
281290 """
291+ expected = to_list (expected )
292+ if self .format :
293+ expected = [self .meta .format_str (v ) for v in expected ]
282294 matchers = [
283- matching .equals_wrapper (expected )
284- for expected in to_list ( expect_contains )
295+ matching .equals_wrapper (e )
296+ for e in expected
285297 ]
286298 return self .contains_at_least_predicates (matchers )
287299
@@ -321,6 +333,8 @@ def _collection_subject_contains_at_least_predicates(self, matchers):
321333 return ordered
322334
323335def _collection_subject_not_contains (self , value ):
336+ if self .format :
337+ value = self .meta .format_str (value )
324338 check_not_contains_predicate (
325339 self .actual ,
326340 matcher = matching .equals_wrapper (value ),
0 commit comments