MCPcopy Create free account
hub / github.com/dateutil/dateutil / test_ybd

Method test_ybd

tests/test_parser.py:228–251  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

226class TestFormat(object):
227
228 def test_ybd(self):
229 # If we have a 4-digit year, a non-numeric month (abbreviated or not),
230 # and a day (1 or 2 digits), then there is no ambiguity as to which
231 # token is a year/month/day. This holds regardless of what order the
232 # terms are in and for each of the separators below.
233
234 seps = ['-', ' ', '/', '.']
235
236 year_tokens = ['%Y']
237 month_tokens = ['%b', '%B']
238 day_tokens = ['%d']
239 if PLATFORM_HAS_DASH_D:
240 day_tokens.append('%-d')
241
242 prods = itertools.product(year_tokens, month_tokens, day_tokens)
243 perms = [y for x in prods for y in itertools.permutations(x)]
244 unambig_fmts = [sep.join(perm) for sep in seps for perm in perms]
245
246 actual = datetime(2003, 9, 25)
247
248 for fmt in unambig_fmts:
249 dstr = actual.strftime(fmt)
250 res = parse(dstr)
251 assert res == actual
252
253 # TODO: some redundancy with PARSER_TEST_CASES cases
254 @pytest.mark.parametrize("fmt,dstr", [

Callers

nothing calls this directly

Calls 2

parseFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected