Bug 956474 - Enforce that keywords in expressions are recognized; r=wlach

This commit is contained in:
Ms2ger 2014-02-09 09:02:44 +01:00
parent bb201bc924
commit e0451f9887
2 changed files with 19 additions and 7 deletions

View File

@ -276,7 +276,7 @@ def parse(text, **values):
:rtype: the final value of the expression.
:raises: :py:exc::ParseError: will be raised if parsing fails.
"""
return ExpressionParser(text, values).parse()
return ExpressionParser(text, values, strict=True).parse()
### path normalization

View File

@ -2,7 +2,7 @@
import os
import unittest
from manifestparser import TestManifest
from manifestparser import TestManifest, ParseError
here = os.path.dirname(os.path.abspath(__file__))
@ -13,22 +13,34 @@ class TestTestManifest(unittest.TestCase):
# Test filtering based on platform:
filter_example = os.path.join(here, 'filter-example.ini')
manifest = TestManifest(manifests=(filter_example,))
self.assertEqual([i['name'] for i in manifest.active_tests(os='win', disabled=False, exists=False)],
self.assertEqual([i['name'] for i in manifest.active_tests(os='win', toolkit='windows', disabled=False, exists=False)],
['windowstest', 'fleem'])
self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', disabled=False, exists=False)],
self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', toolkit='gtk2', disabled=False, exists=False)],
['fleem', 'linuxtest'])
# Look for existing tests. There is only one:
self.assertEqual([i['name'] for i in manifest.active_tests()],
self.assertEqual([i['name'] for i in manifest.active_tests(os='', widget='')],
['fleem'])
# You should be able to expect failures:
last_test = manifest.active_tests(exists=False, toolkit='gtk2')[-1]
last_test = manifest.active_tests(exists=False, toolkit='gtk2', os='linux')[-1]
self.assertEqual(last_test['name'], 'linuxtest')
self.assertEqual(last_test['expected'], 'pass')
last_test = manifest.active_tests(exists=False, toolkit='cocoa')[-1]
last_test = manifest.active_tests(exists=False, toolkit='cocoa', os='mac')[-1]
self.assertEqual(last_test['expected'], 'fail')
def test_unknown_keywords(self):
filter_example = os.path.join(here, 'filter-example.ini')
manifest = TestManifest(manifests=(filter_example,))
with self.assertRaises(ParseError):
# toolkit missing
manifest.active_tests(os='win', disabled=False, exists=False)
with self.assertRaises(ParseError):
# os missing
manifest.active_tests(toolkit='windows', disabled=False, exists=False)
def test_comments(self):
"""
ensure comments work, see