mutmut: mutmut run failed to collect stats
I tried to test inline-snapshot with mutmut but got the following error:
❯ hatch run mutmut run
generating mutants
done in 2062ms
⠇ running stats
done
failed to collect stats, no active tests found
⠸ running clean tests........................................................,..,,,,,....
............. [ 19%]
........F
======================================= FAILURES ========================================
_____________________________________ test_persist ______________________________________
project = <tests.conftest.project.<locals>.Project object at 0x7f63af037050>
def test_persist(project):
project.setup(
"""\
from inline_snapshot import external
def test_something():
assert "hello" == snapshot(external("bbbbb*.txt"))
assert 2 == snapshot(1+1)
"""
)
result = project.run("--inline-snapshot=update")
> assert project.storage() == snapshot([])
/home/frank/projects/inline-snapshot/mutants/tests/test_external.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/frank/projects/inline-snapshot/src/inline_snapshot/_inline_snapshot.py:529: in __ca
ll__
return self.func(*args, **kwargs)
/home/frank/projects/inline-snapshot/src/inline_snapshot/_inline_snapshot.py:593: in snap
shot
snapshots[key]._re_eval(obj)
/home/frank/projects/inline-snapshot/src/inline_snapshot/_inline_snapshot.py:642: in _re_
eval
self._value._re_eval(obj)
/home/frank/projects/inline-snapshot/src/inline_snapshot/_inline_snapshot.py:111: in _re_
eval
re_eval(self._old_value, self._ast_node, value)
/home/frank/projects/inline-snapshot/src/inline_snapshot/_inline_snapshot.py:95: in re_ev
al
old_items = adapter.items(old_value, node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <inline_snapshot._adapter.sequence_adapter.ListAdapter object at 0x7f63a2881c40>
value = [], node = None
def items(self, value, node):
> assert isinstance(node, self.node_type), (node, self)
E AssertionError: (None, <inline_snapshot._adapter.sequence_adapter.ListAdapter obj
ect at 0x7f63a2881c40>)
/home/frank/projects/inline-snapshot/src/inline_snapshot/_adapter/sequence_adapter.py:22:
AssertionError
--------------------------------- Captured stdout call ----------------------------------
write code:
# äöß 🐍
from inline_snapshot import snapshot
from inline_snapshot import outsource
from inline_snapshot import external
def test_something():
assert "hello" == snapshot(external("bbbbb*.txt"))
assert 2 == snapshot(1+1)
running: pytest --inline-snapshot=update
in: /tmp/pytest-of-frank/pytest-396/test_persist1
============================= test session starts ==============================
platform linux -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0
rootdir: /tmp/pytest-of-frank/pytest-396/test_persist1
plugins: inline-snapshot-0.13.3, time-machine-2.16.0, hypothesis-6.115.3, subtests-0.13.1
, xdist-3.6.1
collected 1 item
test_file.py . [100%]
=============================== inline snapshot ================================
──────────────────────────────── Fix snapshots ─────────────────────────────────
+-------------------------------- test_file.py --------------------------------+
| @@ -4,5 +4,5 @@ |
| |
| from inline_snapshot import external |
| |
| def test_something(): |
| - assert "hello" == snapshot(external("bbbbb*.txt")) |
| + assert "hello" == snapshot("hello") |
| assert 2 == snapshot(1+1) |
+------------------------------------------------------------------------------+
These changes are not applied.
Use --inline-snapshot=fix to apply them, or use the interactive mode with
--inline-snapshot=review
─────────────────────────────── Update snapshots ───────────────────────────────
+-------------------------------- test_file.py --------------------------------+
| @@ -5,4 +5,4 @@ |
| |
| |
| def test_something(): |
| assert "hello" == snapshot(external("bbbbb*.txt")) |
| - assert 2 == snapshot(1+1) |
| + assert 2 == snapshot(2) |
+------------------------------------------------------------------------------+
These changes will be applied, because you used --inline-snapshot=update
============================== 1 passed in 0.13s ===============================
==================================== inline snapshot ====================================
=========================== short test summary info ============================
FAILED tests/test_external.py::test_persist - AssertionError: (None, <inline_...
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 83 passed, 6 subtests passed in 8.93s
failed to run clean test
I don’t know if this problem is only caused by mutmut, because inline-snapshot does also some special things with pytest/assert-rewriting and some ast analysis which can have problems when the source code is modified before it is compiled.
I hope you can reproduce the problem in this branch with.
> hatch run mutmut run
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (27 by maintainers)
This issue turned into a pile of issues, many (all?) of which are solved, so I’m closing this. If there are problems still, it’s better to create new issues for that.
You can add it to the
also_copyconfig.Ah. Good point. I pushed a fix for that. Even with that fix I crash here:
I don’t really understand how this happens.
I released 3.1.0 with fixes for
from __future__, stat hard exit, and generator handling. Still no luck in running your project though, but I’m getting a lot further.I added a requirements.txt to my branch and tested it in a normal venv. I got the same problem with
mutmut run, but I was able to executepython -m pytest tests --import-mode=append -x -qinside the mutants directory successfully.My best guess at the moment is that your stats collector plugin causes some problems in combination with my tests. I will later take a look at it again.