hi everyone

since a while now i feel the lack of a place where i can store objects
that belong to some pytest plugin but shouldn't be plugins themselves

i came up with an idea for a basic api and would like to get feedback
from it

at the basic level there would be a `config.objects` or `item.objects`
as "immutable" mapping with 4 extra methods to mutate, i#ll just show
the proposed effects

get_or_create(tp, *k, **kw):
  if tp not in self:
    self[tp] = tp(*k, **kw)
  return self[tp]
create(self, tp, *k, **kw):
  if tp in self:
    raise KeyError(tp)
 self[tp] = tp(*k, **kw)
 return self.tp

 add(obj):
  tp = type(obj)
  if tp in self:
    raise KeyError(tp)
  self[tp] = obj

remove(self, obj):
  del self[type(obj)]

discard(self, obj):
  self.pop(type(obj), None)

by adding such a storage it will be a lot more easy to just put things
on items and reports


-- Ronny

_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to