Make sure that tests fail properly; ensure that empty string is a valid default
This commit is contained in:
parent
4454dead0f
commit
7f77842ab8
2 changed files with 13 additions and 5 deletions
|
|
@ -460,7 +460,7 @@ VAR_MATCH = re.compile(
|
||||||
{(?P<braceddefault> # or An {id:default} - default param, as
|
{(?P<braceddefault> # or An {id:default} - default param, as
|
||||||
(?P<defname>[_a-z][_a-z0-9]*) # an ID
|
(?P<defname>[_a-z][_a-z0-9]*) # an ID
|
||||||
: # then a colon
|
: # then a colon
|
||||||
(?P<default>(?:\\}|[^}])+) # then anything up to }, or a \}
|
(?P<default>(?:\\}|[^}])*) # then anything up to }, or a \}
|
||||||
)} | # then a }
|
)} | # then a }
|
||||||
(?P<invalid>) # or Something else - invalid
|
(?P<invalid>) # or Something else - invalid
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ from vimspector import utils
|
||||||
|
|
||||||
|
|
||||||
class TestExpandReferencesInDict( unittest.TestCase ):
|
class TestExpandReferencesInDict( unittest.TestCase ):
|
||||||
|
def __init__( self, *args, **kwargs ):
|
||||||
|
super().__init__( *args, **kwargs )
|
||||||
|
self.maxDiff = 4096
|
||||||
|
|
||||||
def test_ExpandReferencesInDict( self ):
|
def test_ExpandReferencesInDict( self ):
|
||||||
mapping = {
|
mapping = {
|
||||||
'one': 'one',
|
'one': 'one',
|
||||||
|
|
@ -13,7 +17,7 @@ class TestExpandReferencesInDict( unittest.TestCase ):
|
||||||
'words': 'these are some words'
|
'words': 'these are some words'
|
||||||
}
|
}
|
||||||
calculus = {
|
calculus = {
|
||||||
'three': lambda : 1 + 2
|
'three': lambda : 1 + 2,
|
||||||
}
|
}
|
||||||
CHOICES = {
|
CHOICES = {
|
||||||
'five': '5ive!'
|
'five': '5ive!'
|
||||||
|
|
@ -44,6 +48,8 @@ class TestExpandReferencesInDict( unittest.TestCase ):
|
||||||
'one_default2': '${one_default2:${one\\}}',
|
'one_default2': '${one_default2:${one\\}}',
|
||||||
'two_default2':
|
'two_default2':
|
||||||
'${two_default2_1:${one\\}} and ${two_default2_2:${two\\}}',
|
'${two_default2_1:${one\\}} and ${two_default2_2:${two\\}}',
|
||||||
|
'unlikely_name#json#s': 'true',
|
||||||
|
'empty_splice': [ '*${empty:}' ],
|
||||||
}
|
}
|
||||||
|
|
||||||
e = {
|
e = {
|
||||||
|
|
@ -66,6 +72,8 @@ class TestExpandReferencesInDict( unittest.TestCase ):
|
||||||
'two_default': 'one and two',
|
'two_default': 'one and two',
|
||||||
'one_default2': 'one',
|
'one_default2': 'one',
|
||||||
'two_default2': 'one and TWO',
|
'two_default2': 'one and TWO',
|
||||||
|
'unlikely_name#json': 'true',
|
||||||
|
'empty_splice': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch( 'vimspector.utils.AskForInput', side_effect = AskForInput ):
|
with patch( 'vimspector.utils.AskForInput', side_effect = AskForInput ):
|
||||||
|
|
@ -74,6 +82,6 @@ class TestExpandReferencesInDict( unittest.TestCase ):
|
||||||
self.assertDictEqual( d, e )
|
self.assertDictEqual( d, e )
|
||||||
|
|
||||||
|
|
||||||
unittest.main( module=__name__,
|
assert unittest.main( module=__name__,
|
||||||
testRunner=unittest.TextTestRunner( sys.stdout ),
|
testRunner=unittest.TextTestRunner( sys.stdout ),
|
||||||
exit=False )
|
exit=False ).result.wasSuccessful()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue