Add 'named arguments must follow bare *' issue and a few conftest tweaks.

This commit is contained in:
Dave Halter
2017-07-22 19:00:24 +02:00
parent 1b66fa4d44
commit d76eee2a96
4 changed files with 49 additions and 3 deletions

View File

@@ -109,21 +109,42 @@ def each_py2_version():
class Checker():
def __init__(self, version, is_passing):
self._version = version
self.version = version
self._is_passing = is_passing
def parse(self, code):
if self._is_passing:
return parso.parse(code, version=self._version, error_recovery=False)
return parso.parse(code, version=self.version, error_recovery=False)
else:
self._invalid_syntax(code)
def _invalid_syntax(self, code):
with pytest.raises(parso.ParserSyntaxError):
module = parso.parse(code, version=self._version, error_recovery=False)
module = parso.parse(code, version=self.version, error_recovery=False)
# For debugging
print(module.children)
def get_error(self, code):
errors = list(parso.parse(code, version=self.version)._iter_errors())
assert bool(errors) != self._is_passing
if errors:
return errors[0]
def get_error_message(self, code):
error = self.get_error(code)
if error is None:
return
return error.message
def assert_no_error_in_passing(self, code):
if self._is_passing:
assert not list(parso.parse(code, version=self.version)._iter_errors())
@pytest.fixture
def works_not_in_py(each_version):
return Checker(each_version, False)
@pytest.fixture
def works_in_py2(each_version):