Added tests for macros applied to stuff not currently used.

This commit is contained in:
Salvador E. Tropea 2021-02-04 13:06:44 -03:00
parent 685ab34c56
commit 9f2344ed4a
4 changed files with 21 additions and 8 deletions

View File

@ -189,7 +189,7 @@ class Layer(Optionable):
raise KiPlotConfigurationError("Unknown layer spec: `{}`".format(layer)) raise KiPlotConfigurationError("Unknown layer spec: `{}`".format(layer))
new_vals.extend(ext) new_vals.extend(ext)
return new_vals return new_vals
assert False, "Unimplemented layer type "+str(type(values)) # pragma: no cover (Internal) assert False, "Unimplemented layer type "+str(type(values))
@staticmethod @staticmethod
def _get_copper(): def _get_copper():

View File

@ -33,7 +33,7 @@ def document(sentences, **kw):
value = prev.value value = prev.value
# Extract its name # Extract its name
# variables and attributes are supported # variables and attributes are supported
if isinstance(target, Name): # pragma: no cover (Internal) if isinstance(target, Name):
# Note: The support for variables isn't currently used # Note: The support for variables isn't currently used
name = target.id name = target.id
is_attr = False is_attr = False
@ -65,17 +65,17 @@ def document(sentences, **kw):
val = eval(unparse(value)) val = eval(unparse(value))
if isinstance(val, bool): if isinstance(val, bool):
# Not used yet # Not used yet
type_hint = '[boolean={}]'.format(str(val).lower()) # pragma: no cover (Internal) type_hint = '[boolean={}]'.format(str(val).lower())
elif isinstance(val, (int, float)): elif isinstance(val, (int, float)):
# Not used yet # Not used yet
type_hint = '[number={}]'.format(val) # pragma: no cover (Internal) type_hint = '[number={}]'.format(val)
elif isinstance(val, str): elif isinstance(val, str):
type_hint = "[string='{}']".format(val) type_hint = "[string='{}']".format(val)
post_hint += '. Affected by global options' post_hint += '. Affected by global options'
# Transform the string into an assign for _help_ID # Transform the string into an assign for _help_ID
if is_attr: if is_attr:
target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store()) target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store())
else: # pragma: no cover (Internal) else:
target = Name(id=doc_id, ctx=Store()) target = Name(id=doc_id, ctx=Store())
# Reuse the s.value Str # Reuse the s.value Str
help_str = s.value help_str = s.value
@ -102,7 +102,7 @@ def _do_wrap_class_register(tree, mod, base_class):
do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None)], level=1) do_import = ImportFrom(module=mod, names=[alias(name=base_class, asname=None)], level=1)
return [do_import, tree, do_register] return [do_import, tree, do_register]
# Just in case somebody applies it to anything other than a class # Just in case somebody applies it to anything other than a class
return tree # pragma: no cover (Internal) return tree
def output_class(tree, **kw): def output_class(tree, **kw):

View File

@ -4,6 +4,19 @@ from . import log
logger = log.get_logger(__name__) logger = log.get_logger(__name__)
with document:
avar = 1
""" Documentation """
bvar = True
""" Other doc """
assert _help_avar == '[number=1] Documentation', _help_avar
assert _help_bvar == '[boolean=true] Other doc', _help_bvar
@filter_class
def pp():
pass
@filter_class @filter_class
class Filter_Test(BaseFilter): # noqa: F821 class Filter_Test(BaseFilter): # noqa: F821
def __init__(self): def __init__(self):

View File

@ -13,14 +13,14 @@ from utils import context
prev_dir = os.path.dirname(prev_dir) prev_dir = os.path.dirname(prev_dir)
if prev_dir not in sys.path: if prev_dir not in sys.path:
sys.path.insert(0, prev_dir) sys.path.insert(0, prev_dir)
from kibot.out_base import BaseOutput from kibot.layer import Layer
from kibot.pre_base import BasePreFlight from kibot.pre_base import BasePreFlight
from kibot.out_base import BaseOutput
from kibot.gs import GS from kibot.gs import GS
from kibot.kiplot import load_actions, _import from kibot.kiplot import load_actions, _import
from kibot.registrable import RegOutput, RegFilter from kibot.registrable import RegOutput, RegFilter
from kibot.misc import (MISSING_TOOL, WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR) from kibot.misc import (MISSING_TOOL, WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR)
from kibot.bom.columnlist import ColumnList from kibot.bom.columnlist import ColumnList
from kibot.layer import Layer
cov = coverage.Coverage() cov = coverage.Coverage()