PYTHON-2883 Regex decoding error tests in top.json have unexpected, invalid syntax (#721)
This commit is contained in:
parent
fb38fbe35e
commit
7a4b617b5d
@ -666,7 +666,11 @@ def _parse_canonical_regex(doc):
|
||||
if len(regex) != 2:
|
||||
raise TypeError('Bad $regularExpression must include only "pattern"'
|
||||
'and "options" components: %s' % (doc,))
|
||||
return Regex(regex['pattern'], regex['options'])
|
||||
opts = regex['options']
|
||||
if not isinstance(opts, str):
|
||||
raise TypeError('Bad $regularExpression options, options must be '
|
||||
'string, was type %s' % (type(opts)))
|
||||
return Regex(regex['pattern'], opts)
|
||||
|
||||
|
||||
def _parse_canonical_dbref(doc):
|
||||
|
||||
@ -92,11 +92,11 @@
|
||||
},
|
||||
{
|
||||
"description": "Bad $regularExpression (pattern is number, not string)",
|
||||
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"$options\" : \"\"}}}"
|
||||
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"options\" : \"\"}}}"
|
||||
},
|
||||
{
|
||||
"description": "Bad $regularExpression (options are number, not string)",
|
||||
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"$options\" : 0}}}"
|
||||
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"options\" : 0}}}"
|
||||
},
|
||||
{
|
||||
"description" : "Bad $regularExpression (missing pattern field)",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user