|
51 | 51 | from zipline.lib.labelarray import LabelArray |
52 | 52 | from zipline.testing.core import ensure_doctest |
53 | 53 | from zipline.utils.compat import getargspec, mappingproxy |
| 54 | +from zipline.utils.formatting import s |
54 | 55 | from zipline.utils.functional import dzip_exact, instance |
55 | 56 | from zipline.utils.math_utils import tolerant_equals |
56 | 57 |
|
@@ -175,25 +176,6 @@ def filter_kwargs(f, kwargs): |
175 | 176 | return keyfilter(op.contains(keywords(f)), kwargs) |
176 | 177 |
|
177 | 178 |
|
178 | | -def _s(word, seq, suffix='s'): |
179 | | - """Adds a suffix to ``word`` if some sequence has anything other than |
180 | | - exactly one element. |
181 | | -
|
182 | | - word : str |
183 | | - The string to add the suffix to. |
184 | | - seq : sequence |
185 | | - The sequence to check the length of. |
186 | | - suffix : str, optional. |
187 | | - The suffix to add to ``word`` |
188 | | -
|
189 | | - Returns |
190 | | - ------- |
191 | | - maybe_plural : str |
192 | | - ``word`` with ``suffix`` added if ``len(seq) != 1``. |
193 | | - """ |
194 | | - return word + (suffix if len(seq) != 1 else '') |
195 | | - |
196 | | - |
197 | 179 | def _fmt_path(path): |
198 | 180 | """Format the path for final display. |
199 | 181 |
|
@@ -432,17 +414,17 @@ def _check_sets(result, expected, msg, path, type_): |
432 | 414 | if result != expected: |
433 | 415 | if result > expected: |
434 | 416 | diff = result - expected |
435 | | - msg = 'extra %s in result: %r' % (_s(type_, diff), diff) |
| 417 | + msg = 'extra %s in result: %r' % (s(type_, diff), diff) |
436 | 418 | elif result < expected: |
437 | 419 | diff = expected - result |
438 | | - msg = 'result is missing %s: %r' % (_s(type_, diff), diff) |
| 420 | + msg = 'result is missing %s: %r' % (s(type_, diff), diff) |
439 | 421 | else: |
440 | 422 | in_result = result - expected |
441 | 423 | in_expected = expected - result |
442 | 424 | msg = '%s only in result: %s\n%s only in expected: %s' % ( |
443 | | - _s(type_, in_result), |
| 425 | + s(type_, in_result), |
444 | 426 | in_result, |
445 | | - _s(type_, in_expected), |
| 427 | + s(type_, in_expected), |
446 | 428 | in_expected, |
447 | 429 | ) |
448 | 430 | raise AssertionError( |
|
0 commit comments