2010-10-13 18:26:14 +08:00
|
|
|
""" generic mechanism for marking and selecting python functions. """
|
2017-03-17 09:21:30 +08:00
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2015-07-16 08:03:30 +08:00
|
|
|
import inspect
|
2016-09-08 15:52:22 +08:00
|
|
|
from collections import namedtuple
|
|
|
|
from operator import attrgetter
|
2016-09-08 16:03:45 +08:00
|
|
|
from .compat import imap
|
2016-09-08 15:52:22 +08:00
|
|
|
|
2016-09-07 17:00:27 +08:00
|
|
|
|
2016-09-08 15:52:22 +08:00
|
|
|
def alias(name):
|
|
|
|
return property(attrgetter(name), doc='alias for ' + name)
|
2009-06-28 19:19:43 +08:00
|
|
|
|
2015-03-24 04:28:29 +08:00
|
|
|
|
2016-09-07 17:00:27 +08:00
|
|
|
class ParameterSet(namedtuple('ParameterSet', 'values, marks, id')):
|
|
|
|
@classmethod
|
|
|
|
def param(cls, *values, **kw):
|
|
|
|
marks = kw.pop('marks', ())
|
|
|
|
if isinstance(marks, MarkDecorator):
|
|
|
|
marks = marks,
|
|
|
|
else:
|
|
|
|
assert isinstance(marks, (tuple, list, set))
|
|
|
|
|
|
|
|
def param_extract_id(id=None):
|
|
|
|
return id
|
|
|
|
|
|
|
|
id = param_extract_id(**kw)
|
|
|
|
return cls(values, marks, id)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def extract_from(cls, parameterset, legacy_force_tuple=False):
|
|
|
|
"""
|
|
|
|
:param parameterset:
|
|
|
|
a legacy style parameterset that may or may not be a tuple,
|
|
|
|
and may or may not be wrapped into a mess of mark objects
|
|
|
|
|
|
|
|
:param legacy_force_tuple:
|
|
|
|
enforce tuple wrapping so single argument tuple values
|
|
|
|
don't get decomposed and break tests
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if isinstance(parameterset, cls):
|
|
|
|
return parameterset
|
|
|
|
if not isinstance(parameterset, MarkDecorator) and legacy_force_tuple:
|
|
|
|
return cls.param(parameterset)
|
|
|
|
|
|
|
|
newmarks = []
|
|
|
|
argval = parameterset
|
|
|
|
while isinstance(argval, MarkDecorator):
|
|
|
|
newmarks.append(MarkDecorator(Mark(
|
|
|
|
argval.markname, argval.args[:-1], argval.kwargs)))
|
|
|
|
argval = argval.args[-1]
|
|
|
|
assert not isinstance(argval, ParameterSet)
|
|
|
|
if legacy_force_tuple:
|
|
|
|
argval = argval,
|
|
|
|
|
|
|
|
return cls(argval, marks=newmarks, id=None)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def deprecated_arg_dict(self):
|
|
|
|
return dict((mark.name, mark) for mark in self.marks)
|
|
|
|
|
|
|
|
|
2015-03-24 03:01:58 +08:00
|
|
|
class MarkerError(Exception):
|
2015-03-24 04:28:29 +08:00
|
|
|
|
|
|
|
"""Error in use of a pytest marker/attribute."""
|
2015-03-24 03:01:58 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2017-03-21 00:58:34 +08:00
|
|
|
def param(*values, **kw):
|
|
|
|
return ParameterSet.param(*values, **kw)
|
2009-06-28 19:19:43 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2010-10-12 19:05:29 +08:00
|
|
|
def pytest_addoption(parser):
|
|
|
|
group = parser.getgroup("general")
|
2013-05-20 20:37:58 +08:00
|
|
|
group._addoption(
|
|
|
|
'-k',
|
2013-04-16 15:04:05 +08:00
|
|
|
action="store", dest="keyword", default='', metavar="EXPRESSION",
|
|
|
|
help="only run tests which match the given substring expression. "
|
2012-11-20 21:20:39 +08:00
|
|
|
"An expression is a python evaluatable expression "
|
2013-05-22 13:41:46 +08:00
|
|
|
"where all names are substring-matched against test names "
|
2016-09-05 16:48:04 +08:00
|
|
|
"and their parent classes. Example: -k 'test_method or test_"
|
2013-05-20 20:37:58 +08:00
|
|
|
"other' matches all test functions and classes whose name "
|
|
|
|
"contains 'test_method' or 'test_other'. "
|
|
|
|
"Additionally keywords are matched to classes and functions "
|
2013-05-28 00:14:35 +08:00
|
|
|
"containing extra names in their 'extra_keyword_matches' set, "
|
2013-05-20 20:37:58 +08:00
|
|
|
"as well as functions which have names assigned directly to them."
|
|
|
|
)
|
2010-10-12 19:05:29 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
group._addoption(
|
|
|
|
"-m",
|
2011-11-12 07:02:06 +08:00
|
|
|
action="store", dest="markexpr", default="", metavar="MARKEXPR",
|
2011-11-19 02:32:11 +08:00
|
|
|
help="only run tests matching given mark expression. "
|
|
|
|
"example: -m 'mark1 and not mark2'."
|
2013-05-20 20:37:58 +08:00
|
|
|
)
|
2011-11-12 07:02:06 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
group.addoption(
|
|
|
|
"--markers", action="store_true",
|
|
|
|
help="show markers (builtin, plugin and per-project ones)."
|
|
|
|
)
|
2011-11-12 06:56:11 +08:00
|
|
|
|
|
|
|
parser.addini("markers", "markers for test functions", 'linelist')
|
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2011-11-12 06:56:11 +08:00
|
|
|
def pytest_cmdline_main(config):
|
2015-07-19 03:39:55 +08:00
|
|
|
import _pytest.config
|
2011-11-12 06:56:11 +08:00
|
|
|
if config.option.markers:
|
2015-04-22 22:33:20 +08:00
|
|
|
config._do_configure()
|
2015-07-19 03:39:55 +08:00
|
|
|
tw = _pytest.config.create_terminal_writer(config)
|
2011-11-12 06:56:11 +08:00
|
|
|
for line in config.getini("markers"):
|
|
|
|
name, rest = line.split(":", 1)
|
2013-05-20 20:37:58 +08:00
|
|
|
tw.write("@pytest.mark.%s:" % name, bold=True)
|
2011-11-12 06:56:11 +08:00
|
|
|
tw.line(rest)
|
|
|
|
tw.line()
|
2015-04-22 22:33:20 +08:00
|
|
|
config._ensure_unconfigure()
|
2011-11-12 06:56:11 +08:00
|
|
|
return 0
|
2016-11-21 04:59:15 +08:00
|
|
|
|
|
|
|
|
2011-11-12 06:56:11 +08:00
|
|
|
pytest_cmdline_main.tryfirst = True
|
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2010-10-12 19:05:29 +08:00
|
|
|
def pytest_collection_modifyitems(items, config):
|
2016-04-01 13:20:22 +08:00
|
|
|
keywordexpr = config.option.keyword.lstrip()
|
2011-11-12 07:02:06 +08:00
|
|
|
matchexpr = config.option.markexpr
|
|
|
|
if not keywordexpr and not matchexpr:
|
2010-10-12 19:05:29 +08:00
|
|
|
return
|
2014-10-06 18:11:48 +08:00
|
|
|
# pytest used to allow "-" for negating
|
|
|
|
# but today we just allow "-" at the beginning, use "not" instead
|
2017-02-15 23:00:18 +08:00
|
|
|
# we probably remove "-" altogether soon
|
2014-10-06 18:11:48 +08:00
|
|
|
if keywordexpr.startswith("-"):
|
|
|
|
keywordexpr = "not " + keywordexpr[1:]
|
2010-10-12 19:05:29 +08:00
|
|
|
selectuntil = False
|
2011-11-12 07:02:06 +08:00
|
|
|
if keywordexpr[-1:] == ":":
|
2010-10-12 19:05:29 +08:00
|
|
|
selectuntil = True
|
|
|
|
keywordexpr = keywordexpr[:-1]
|
|
|
|
|
|
|
|
remaining = []
|
|
|
|
deselected = []
|
|
|
|
for colitem in items:
|
2012-11-09 19:29:33 +08:00
|
|
|
if keywordexpr and not matchkeyword(colitem, keywordexpr):
|
2010-10-12 19:05:29 +08:00
|
|
|
deselected.append(colitem)
|
|
|
|
else:
|
|
|
|
if selectuntil:
|
|
|
|
keywordexpr = None
|
2011-11-12 07:02:06 +08:00
|
|
|
if matchexpr:
|
|
|
|
if not matchmark(colitem, matchexpr):
|
|
|
|
deselected.append(colitem)
|
|
|
|
continue
|
|
|
|
remaining.append(colitem)
|
2010-10-12 19:05:29 +08:00
|
|
|
|
|
|
|
if deselected:
|
|
|
|
config.hook.pytest_deselected(items=deselected)
|
|
|
|
items[:] = remaining
|
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2017-05-18 05:16:11 +08:00
|
|
|
class MarkMapping:
|
2013-10-03 21:43:56 +08:00
|
|
|
"""Provides a local mapping for markers where item access
|
|
|
|
resolves to True if the marker is present. """
|
2013-05-20 20:37:58 +08:00
|
|
|
def __init__(self, keywords):
|
2013-05-28 00:14:35 +08:00
|
|
|
mymarks = set()
|
2013-05-20 20:37:58 +08:00
|
|
|
for key, value in keywords.items():
|
|
|
|
if isinstance(value, MarkInfo) or isinstance(value, MarkDecorator):
|
2013-05-28 00:14:35 +08:00
|
|
|
mymarks.add(key)
|
2013-05-20 20:37:58 +08:00
|
|
|
self._mymarks = mymarks
|
|
|
|
|
2013-10-03 21:43:56 +08:00
|
|
|
def __getitem__(self, name):
|
|
|
|
return name in self._mymarks
|
2013-05-20 20:37:58 +08:00
|
|
|
|
|
|
|
|
2017-05-18 05:16:11 +08:00
|
|
|
class KeywordMapping:
|
2013-05-20 20:37:58 +08:00
|
|
|
"""Provides a local mapping for keywords.
|
|
|
|
Given a list of names, map any substring of one of these names to True.
|
|
|
|
"""
|
|
|
|
def __init__(self, names):
|
|
|
|
self._names = names
|
|
|
|
|
|
|
|
def __getitem__(self, subname):
|
|
|
|
for name in self._names:
|
|
|
|
if subname in name:
|
2012-11-09 19:29:33 +08:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
|
|
|
def matchmark(colitem, markexpr):
|
|
|
|
"""Tries to match on any marker names, attached to the given colitem."""
|
|
|
|
return eval(markexpr, {}, MarkMapping(colitem.keywords))
|
|
|
|
|
2011-11-12 07:02:06 +08:00
|
|
|
|
2012-11-09 19:29:33 +08:00
|
|
|
def matchkeyword(colitem, keywordexpr):
|
2013-05-20 20:37:58 +08:00
|
|
|
"""Tries to match given keyword expression to given collector item.
|
|
|
|
|
|
|
|
Will match on the name of colitem, including the names of its parents.
|
|
|
|
Only matches names of items which are either a :class:`Class` or a
|
|
|
|
:class:`Function`.
|
2013-05-28 00:14:35 +08:00
|
|
|
Additionally, matches on names in the 'extra_keyword_matches' set of
|
2013-05-20 20:37:58 +08:00
|
|
|
any item, as well as names directly assigned to test functions.
|
|
|
|
"""
|
2013-05-28 00:14:35 +08:00
|
|
|
mapped_names = set()
|
2013-05-20 20:37:58 +08:00
|
|
|
|
|
|
|
# Add the names of the current item and any parent items
|
2013-09-30 19:14:14 +08:00
|
|
|
import pytest
|
2013-05-20 20:37:58 +08:00
|
|
|
for item in colitem.listchain():
|
2013-05-27 23:58:39 +08:00
|
|
|
if not isinstance(item, pytest.Instance):
|
2013-05-28 00:14:35 +08:00
|
|
|
mapped_names.add(item.name)
|
2013-05-20 20:37:58 +08:00
|
|
|
|
|
|
|
# Add the names added as extra keywords to current or parent items
|
|
|
|
for name in colitem.listextrakeywords():
|
2013-05-28 00:14:35 +08:00
|
|
|
mapped_names.add(name)
|
2013-05-20 20:37:58 +08:00
|
|
|
|
|
|
|
# Add the names attached to the current function through direct assignment
|
2013-10-02 21:55:28 +08:00
|
|
|
if hasattr(colitem, 'function'):
|
|
|
|
for name in colitem.function.__dict__:
|
|
|
|
mapped_names.add(name)
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2013-11-21 22:25:16 +08:00
|
|
|
mapping = KeywordMapping(mapped_names)
|
|
|
|
if " " not in keywordexpr:
|
|
|
|
# special case to allow for simple "-k pass" and "-k 1.3"
|
|
|
|
return mapping[keywordexpr]
|
|
|
|
elif keywordexpr.startswith("not ") and " " not in keywordexpr[4:]:
|
|
|
|
return not mapping[keywordexpr[4:]]
|
|
|
|
return eval(keywordexpr, {}, mapping)
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2012-11-09 19:29:33 +08:00
|
|
|
|
2011-11-12 06:56:11 +08:00
|
|
|
def pytest_configure(config):
|
2017-02-28 23:58:29 +08:00
|
|
|
config._old_mark_config = MARK_GEN._config
|
2011-11-12 06:56:11 +08:00
|
|
|
if config.option.strict:
|
2017-02-28 23:58:29 +08:00
|
|
|
MARK_GEN._config = config
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_unconfigure(config):
|
2017-03-01 00:30:52 +08:00
|
|
|
MARK_GEN._config = getattr(config, '_old_mark_config', None)
|
2011-11-12 06:56:11 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2017-05-18 05:16:11 +08:00
|
|
|
class MarkGenerator:
|
2010-11-06 18:38:53 +08:00
|
|
|
""" Factory for :class:`MarkDecorator` objects - exposed as
|
2014-01-18 19:31:33 +08:00
|
|
|
a ``pytest.mark`` singleton instance. Example::
|
2010-10-14 01:30:00 +08:00
|
|
|
|
2016-02-27 21:15:42 +08:00
|
|
|
import pytest
|
2014-01-18 19:31:33 +08:00
|
|
|
@pytest.mark.slowtest
|
2010-10-14 01:30:00 +08:00
|
|
|
def test_function():
|
|
|
|
pass
|
2011-11-12 06:56:11 +08:00
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
will set a 'slowtest' :class:`MarkInfo` object
|
|
|
|
on the ``test_function`` object. """
|
2017-02-28 23:58:29 +08:00
|
|
|
_config = None
|
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
|
2009-06-28 19:19:43 +08:00
|
|
|
def __getattr__(self, name):
|
|
|
|
if name[0] == "_":
|
2013-12-19 21:29:57 +08:00
|
|
|
raise AttributeError("Marker name must NOT start with underscore")
|
2017-02-28 23:58:29 +08:00
|
|
|
if self._config is not None:
|
2011-11-12 06:56:11 +08:00
|
|
|
self._check(name)
|
2016-09-08 15:52:22 +08:00
|
|
|
return MarkDecorator(Mark(name, (), {}))
|
2009-06-28 19:19:43 +08:00
|
|
|
|
2011-11-12 06:56:11 +08:00
|
|
|
def _check(self, name):
|
|
|
|
try:
|
|
|
|
if name in self._markers:
|
|
|
|
return
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
self._markers = l = set()
|
|
|
|
for line in self._config.getini("markers"):
|
|
|
|
beginning = line.split(":", 1)
|
|
|
|
x = beginning[0].split("(", 1)[0]
|
|
|
|
l.add(x)
|
|
|
|
if name not in self._markers:
|
|
|
|
raise AttributeError("%r not a registered marker" % (name,))
|
|
|
|
|
2017-02-28 23:58:29 +08:00
|
|
|
|
2013-10-11 20:36:54 +08:00
|
|
|
def istestfunc(func):
|
|
|
|
return hasattr(func, "__call__") and \
|
|
|
|
getattr(func, "__name__", "<lambda>") != "<lambda>"
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2017-05-18 05:16:11 +08:00
|
|
|
class MarkDecorator:
|
2010-10-14 01:30:00 +08:00
|
|
|
""" A decorator for test functions and test classes. When applied
|
2010-11-06 18:38:53 +08:00
|
|
|
it will create :class:`MarkInfo` objects which may be
|
2011-02-09 21:55:21 +08:00
|
|
|
:ref:`retrieved by hooks as item keywords <excontrolskip>`.
|
|
|
|
MarkDecorator instances are often created like this::
|
2010-10-14 01:30:00 +08:00
|
|
|
|
2014-01-18 19:31:33 +08:00
|
|
|
mark1 = pytest.mark.NAME # simple MarkDecorator
|
|
|
|
mark2 = pytest.mark.NAME(name1=value) # parametrized MarkDecorator
|
2010-10-14 01:30:00 +08:00
|
|
|
|
|
|
|
and can then be applied as decorators to test functions::
|
|
|
|
|
|
|
|
@mark2
|
|
|
|
def test_function():
|
|
|
|
pass
|
2014-01-20 08:27:33 +08:00
|
|
|
|
|
|
|
When a MarkDecorator instance is called it does the following:
|
|
|
|
1. If called with a single class as its only positional argument and no
|
|
|
|
additional keyword arguments, it attaches itself to the class so it
|
|
|
|
gets applied automatically to all test cases found in that class.
|
|
|
|
2. If called with a single function as its only positional argument and
|
|
|
|
no additional keyword arguments, it attaches a MarkInfo object to the
|
|
|
|
function, containing all the arguments already stored internally in
|
|
|
|
the MarkDecorator.
|
|
|
|
3. When called in any other case, it performs a 'fake construction' call,
|
|
|
|
i.e. it returns a new MarkDecorator instance with the original
|
|
|
|
MarkDecorator's content updated with the arguments passed to this
|
|
|
|
call.
|
|
|
|
|
|
|
|
Note: The rules above prevent MarkDecorator objects from storing only a
|
|
|
|
single function or class reference as their positional argument with no
|
|
|
|
additional keyword or positional arguments.
|
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
"""
|
2016-09-08 15:52:22 +08:00
|
|
|
def __init__(self, mark):
|
|
|
|
assert isinstance(mark, Mark), repr(mark)
|
|
|
|
self.mark = mark
|
|
|
|
|
|
|
|
name = alias('mark.name')
|
|
|
|
args = alias('mark.args')
|
|
|
|
kwargs = alias('mark.kwargs')
|
2009-06-28 19:19:43 +08:00
|
|
|
|
2013-10-03 21:43:56 +08:00
|
|
|
@property
|
|
|
|
def markname(self):
|
|
|
|
return self.name # for backward-compat (2.4.1 had this attr)
|
|
|
|
|
2016-09-07 17:00:27 +08:00
|
|
|
def __eq__(self, other):
|
|
|
|
return self.mark == other.mark
|
|
|
|
|
2009-07-28 20:26:32 +08:00
|
|
|
def __repr__(self):
|
2016-09-07 17:00:27 +08:00
|
|
|
return "<MarkDecorator %r>" % (self.mark,)
|
2009-06-28 19:19:43 +08:00
|
|
|
|
2009-07-28 20:26:32 +08:00
|
|
|
def __call__(self, *args, **kwargs):
|
2010-07-27 03:15:15 +08:00
|
|
|
""" if passed a single callable argument: decorate it with mark info.
|
2009-12-29 23:29:48 +08:00
|
|
|
otherwise add *args/**kwargs in-place to mark information. """
|
2014-01-20 08:27:33 +08:00
|
|
|
if args and not kwargs:
|
2010-05-22 00:11:47 +08:00
|
|
|
func = args[0]
|
2015-07-16 08:03:30 +08:00
|
|
|
is_class = inspect.isclass(func)
|
|
|
|
if len(args) == 1 and (istestfunc(func) or is_class):
|
|
|
|
if is_class:
|
2010-05-22 16:12:57 +08:00
|
|
|
if hasattr(func, 'pytestmark'):
|
2015-07-16 08:03:30 +08:00
|
|
|
mark_list = func.pytestmark
|
|
|
|
if not isinstance(mark_list, list):
|
|
|
|
mark_list = [mark_list]
|
|
|
|
# always work on a copy to avoid updating pytestmark
|
|
|
|
# from a superclass by accident
|
|
|
|
mark_list = mark_list + [self]
|
|
|
|
func.pytestmark = mark_list
|
2010-05-22 16:12:57 +08:00
|
|
|
else:
|
2013-05-20 20:37:58 +08:00
|
|
|
func.pytestmark = [self]
|
2009-10-22 21:21:58 +08:00
|
|
|
else:
|
2013-10-03 21:43:56 +08:00
|
|
|
holder = getattr(func, self.name, None)
|
2010-05-22 00:11:47 +08:00
|
|
|
if holder is None:
|
2016-09-08 15:52:22 +08:00
|
|
|
holder = MarkInfo(self.mark)
|
2013-10-03 21:43:56 +08:00
|
|
|
setattr(func, self.name, holder)
|
2010-05-22 00:11:47 +08:00
|
|
|
else:
|
2016-09-08 15:52:22 +08:00
|
|
|
holder.add_mark(self.mark)
|
2009-10-15 22:18:57 +08:00
|
|
|
return func
|
2016-09-08 15:52:22 +08:00
|
|
|
|
|
|
|
mark = Mark(self.name, args, kwargs)
|
|
|
|
return self.__class__(self.mark.combined_with(mark))
|
2010-07-27 03:15:15 +08:00
|
|
|
|
2013-05-20 20:37:58 +08:00
|
|
|
|
2016-09-07 17:00:27 +08:00
|
|
|
|
2016-08-22 02:44:37 +08:00
|
|
|
|
|
|
|
|
2016-09-08 15:52:22 +08:00
|
|
|
class Mark(namedtuple('Mark', 'name, args, kwargs')):
|
|
|
|
|
|
|
|
def combined_with(self, other):
|
|
|
|
assert self.name == other.name
|
|
|
|
return Mark(
|
|
|
|
self.name, self.args + other.args,
|
|
|
|
dict(self.kwargs, **other.kwargs))
|
|
|
|
|
|
|
|
|
|
|
|
class MarkInfo(object):
|
2010-10-14 01:30:00 +08:00
|
|
|
""" Marking object created by :class:`MarkDecorator` instances. """
|
2016-09-08 15:52:22 +08:00
|
|
|
def __init__(self, mark):
|
|
|
|
assert isinstance(mark, Mark), repr(mark)
|
|
|
|
self.combined = mark
|
|
|
|
self._marks = [mark]
|
|
|
|
|
|
|
|
name = alias('combined.name')
|
|
|
|
args = alias('combined.args')
|
|
|
|
kwargs = alias('combined.kwargs')
|
2009-10-23 02:57:21 +08:00
|
|
|
|
2009-10-22 21:21:58 +08:00
|
|
|
def __repr__(self):
|
2016-09-08 15:52:22 +08:00
|
|
|
return "<MarkInfo {0!r}>".format(self.combined)
|
2010-07-27 03:15:15 +08:00
|
|
|
|
2016-09-08 15:52:22 +08:00
|
|
|
def add_mark(self, mark):
|
2011-12-28 23:47:18 +08:00
|
|
|
""" add a MarkInfo with the given args and kwargs. """
|
2016-09-08 15:52:22 +08:00
|
|
|
self._marks.append(mark)
|
|
|
|
self.combined = self.combined.combined_with(mark)
|
2011-12-28 23:47:18 +08:00
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
""" yield MarkInfo objects each relating to a marking-call. """
|
2016-09-08 15:52:22 +08:00
|
|
|
return imap(MarkInfo, self._marks)
|
2017-02-28 23:58:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
MARK_GEN = MarkGenerator()
|