Add test_settings_syntax.py and supporting test data files in "unpythonized" format to skirt by the RUFF/Black format/linters.

This commit is contained in:
egberts 2024-07-23 21:25:35 -05:00
commit ea1fd1be11
6 changed files with 38 additions and 39 deletions

View file

@ -15,7 +15,8 @@ from collections.abc import Iterable
# locations in the file system (e.g. pip with `-e` or `--user`)
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
if "__path__" in globals():
__path__ = extend_path(__path__, __name__)
# pelican.log has to be the first pelican module to be loaded
# because logging.setLoggerClass has to be called before logging.getLogger

View file

@ -2,12 +2,12 @@
# Error to occur is at line 13, column 5
# CAUTION: do not change this error location without corresponding changes in test cases
import me
import os
def function_a(arg1):
value2 = arg1
value3 = value2 + 1
value3 = value2 + 1
return value3
int i

View file

@ -1,14 +1,8 @@
#! Ohhhtay, this is not a python file despite it's .py file extension
# Error to occur is at line 13, column 5
# CAUTION: do not change this error location without corresponding changes in test cases
import me
# Error to occur is at line 5, column 2
def function_a(arg1):
value2 = arg1
value3 = value2 + 1
return value3
// put some C code in it
int i

View file

@ -1,18 +1,18 @@
#! Ohhhtay, this is not a python file despite it's .py file extension
# Error to occur is at line 13, column 5
# Error to occur is at line 9, column 29
# CAUTION: do not change this error location without corresponding changes in test cases
import me
def function_a(arg1):
value1 = [ 'a', 'b', 'c' }
value2 = arg1
value3 = value2 + 1
return value3
int i
for (i = 1; i < 200; ) {
for (i = 1; i < 200; ) {
i = i + 1;
}

View file

@ -1,12 +1,16 @@
#! Ohhhtay, this is not a python file despite it's .py file extension
# Error to occur is at line 13, column 5
# CAUTION: do not change this error location without corresponding changes in test cases
# Error to occur is at line 5, column 2
import os
// put some C code in it
def function_a(arg1):
int i
value2 = arg1
value3 = value2 + 1
return value3
for (i = 1; i < 200; ) {
for (i = 1; i < 200; ) {
i = i + 1;
}
}

View file

@ -64,14 +64,14 @@ BLOB_FULLNAME_SYNTAX3_ERROR = PC_FULLNAME_SYNTAX3_ERROR + EXT_PYTHON_DISABLED
BLOB_FULLNAME_SYNTAX4_ERROR = PC_FULLNAME_SYNTAX4_ERROR + EXT_PYTHON_DISABLED
# SyntaxError placement for use with settings/pelicanconf-syntax-error.py
SM_UT_SYNTAX_INDENT1_LINENO = 5 # tests/settings/pelicanconf-indent-error1.py.disabled
SM_UT_SYNTAX_INDENT1_OFFSET = 1 # tests/settings/pelicanconf-indent-error1.py.disabled
SM_UT_SYNTAX_INDENT2_LINENO = 13 # tests/settings/pelicanconf-indent-error2.py.disabled
SM_UT_SYNTAX_INDENT2_OFFSET = 5 # tests/settings/pelicanconf-indent-error2.py.disabled
SM_UT_SYNTAX_ERROR3_LINENO = 13 # tests/settings/pelicanconf-syntax-error3.py.disabled
SM_UT_SYNTAX_ERROR3_OFFSET = 5 # tests/settings/pelicanconf-syntax-error3.py.disabled
SM_UT_SYNTAX_ERROR4_LINENO = 5 # tests/settings/pelicanconf-syntax-error4.py.disabled
SM_UT_SYNTAX_ERROR4_OFFSET = 1 # tests/settings/pelicanconf-syntax-error4.py.disabled
SM_UT_SYNTAX_INDENT1_LINENO = 10 # tests/settings/pelicanconf-indent-error1.py.disabled
SM_UT_SYNTAX_INDENT1_OFFSET = 7 # tests/settings/pelicanconf-indent-error1.py.disabled
SM_UT_SYNTAX_INDENT2_LINENO = 5 # tests/settings/pelicanconf-indent-error2.py.disabled
SM_UT_SYNTAX_INDENT2_OFFSET = 1 # tests/settings/pelicanconf-indent-error2.py.disabled
SM_UT_SYNTAX_ERROR3_LINENO = 9 # tests/settings/pelicanconf-syntax-error3.py.disabled
SM_UT_SYNTAX_ERROR3_OFFSET = 30 # tests/settings/pelicanconf-syntax-error3.py.disabled
SM_UT_SYNTAX_ERROR4_LINENO = 13 # tests/settings/pelicanconf-syntax-error4.py.disabled
SM_UT_SYNTAX_ERROR4_OFFSET = 10 # tests/settings/pelicanconf-syntax-error4.py.disabled
load_source_argument_list_count = 2
@ -319,10 +319,10 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(default_module, str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
# TODO Issue #09005 - say something to the end-user exactly where syntax err is
# assert "unexpected indent" in self._caplog.text
@ -356,10 +356,10 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(default_module, str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
# TODO Issue #09005 - say something to the end-user exactly where syntax err is
# assert "unexpected indent" in self._caplog.text
@ -393,10 +393,10 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(default_module, str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
# TODO Issue #09005 - say something to the end-user exactly where syntax err is
# assert "unexpected indent" in self._caplog.text
@ -430,10 +430,10 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(default_module, str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
# TODO Issue #09005 - say something to the end-user exactly where syntax err is
# assert "unexpected indent" in self._caplog.text
@ -466,10 +466,10 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(default_module, str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
# TODO Issue #09005 - say something to the end-user exactly where syntax err is
# assert "unexpected indent" in self._caplog.text
@ -503,11 +503,11 @@ class TestSettingsSyntax:
with self._caplog.at_level(logging.DEBUG):
self._caplog.clear()
with pytest.raises(SyntaxError) as sample:
with pytest.raises(IndentationError) as sample:
# ignore return value due to sys.exit()
load_source(indent_error_module, path=str(indent_error_file))
assert sample.type == SyntaxError
assert sample.type == IndentationError
assert sample.value.lineno == SM_UT_SYNTAX_INDENT2_LINENO
assert sample.value.offset == SM_UT_SYNTAX_INDENT2_OFFSET
# Would be nice if a STDERR says something to end-user WHERE