File: test_pypy.py

package info (click to toggle)
python-inline-snapshot 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,116 kB
  • sloc: python: 6,888; makefile: 34; sh: 28
file content (44 lines) | stat: -rw-r--r-- 1,574 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys

import pytest

from inline_snapshot import snapshot
from inline_snapshot.testing import Example


@pytest.mark.no_rewriting
def test_pypy():

    no_cpython = sys.implementation.name != "cpython"

    report = (
        snapshot("INFO: inline-snapshot was disabled because pypy is not supported")
        if sys.implementation.name == "pypy"
        else snapshot(
            """\
-------------------------------- Fix snapshots ---------------------------------
+----------------------------- test_something.py ------------------------------+
| @@ -1,6 +1,6 @@                                                              |
|                                                                              |
|  from inline_snapshot import snapshot                                        |
|                                                                              |
|  def test_example():                                                         |
| -    assert 1+1==snapshot(3)                                                 |
| +    assert 1+1==snapshot(2)                                                 |
+------------------------------------------------------------------------------+
These changes will be applied, because you used fix\
"""
        )
    )

    Example(
        """\
from inline_snapshot import snapshot

def test_example():
    assert 1+1==snapshot(3)

    """
    ).run_pytest(["--inline-snapshot=fix"], report=report, returncode=1).run_pytest(
        ["--inline-snapshot=disable"], report="", returncode=1 if no_cpython else 0
    )