logilab-common #9606 pytest: wrong tb when error under assertRaises [resolved]

syt@scorpius:~/src/fcubicweb/cubes/vcsfile/test$ pytest unittest_write.py error_new_file -x
========================  unittest_write.py  =========================
E
======================================================================
ERROR: test_error_new_file (unittest_write.HGSourceWriteTC)
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/home/syt/src/fcubicweb/cubes/vcsfile/test/unittest_write.py", line 185, in test_error_new_file
    {'repo': self.repoeid, 'dir': u'dir1', 'name': u'tutu.txt'})
TypeError: __init__() takes exactly 2 arguments (3 given)

while the expected tb is:

syt@scorpius:~/src/fcubicweb/cubes/vcsfile/test$ pytest unittest_write.py error_new_file -x
========================  unittest_write.py  =========================
E
======================================================================
ERROR: test_error_new_file (unittest_write.HGSourceWriteTC)
----------------------------------------------------------------------
Traceback (most recent call last)
 File "/home/syt/src/fcubicweb/cubes/vcsfile/test/unittest_write.py", line 184, in test_error_new_file
  'WHERE R eid %(repo)s', {'repo': self.repoeid, 'dir': u'dir1', 'name': u'tutu.txt'})
 File "/home/syt/src/logilab/common/pytest.py", line 168, in not_covered
  return func(*args, **kwargs)
 File "/home/syt/src/fcubicweb/cubicweb/devtools/apptest.py", line 131, in execute
  return self.env.execute(*args, **kwargs)
 File "/home/syt/src/fcubicweb/cubicweb/devtools/_apptest.py", line 160, in execute
  return self.cnx.cursor(req).execute(unicode(rql), args, eidkey)
 File "/home/syt/src/fcubicweb/cubicweb/dbapi.py", line 586, in execute
  parameters, eid_key, build_descr)
 File "/home/syt/src/fcubicweb/cubicweb/server/repository.py", line 592, in execute
  build_descr)
 File "/home/syt/src/fcubicweb/cubicweb/devtools/__init__.py", line 268, in new_execute
  rset = base_execute(*args, **kwargs)
 File "/home/syt/src/fcubicweb/cubicweb/server/querier.py", line 649, in execute
  results = plan.execute()
 File "/home/syt/src/fcubicweb/cubicweb/server/querier.py", line 161, in execute
  result = step.execute()
 File "/home/syt/src/fcubicweb/cubicweb/server/ssplanner.py", line 427, in execute
  result = self.plan.insert_entity_defs()
 File "/home/syt/src/fcubicweb/cubicweb/server/querier.py", line 492, in insert_entity_defs
  for edef in row])
 File "/home/syt/src/fcubicweb/cubicweb/server/repository.py", line 998, in glob_add_entity
  self.hm.call_hooks('before_add_entity', etype, session, entity)
 File "/home/syt/src/fcubicweb/cubicweb/server/hooksmanager.py", line 112, in call_hooks
  hook(*args, **kwargs)
 File "/home/syt/src/fcubicweb/cubes/vcsfile/hooks.py", line 205, in call
  CheckVersionedFileOp(session, entity)
TypeError: __init__() takes exactly 2 arguments (3 given)

problem seems in testlib around:

# count number of relevant levels in the traceback: skip first since
# it's our own _proceed function, and then start counting, using
# unittest's heuristic
nb_frames_skipped = self._count_relevant_tb_levels(tb.tb_next)
for index, (frame, filename, lineno, funcname, ctx, ctxindex) in enumerate(frames):
    if not (0 < index <= nb_frames_skipped):
        continue
priorityimportant
typebug
done in0.44.0
load0.500
load left0.000
closed by<not specified>