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

Method test_ybd

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

parseFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected