File: test_image_compare.py

package info (click to toggle)
f3d 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,504 kB
  • sloc: cpp: 99,106; python: 758; sh: 342; xml: 223; java: 101; javascript: 95; makefile: 25
file content (25 lines) | stat: -rw-r--r-- 678 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
from pathlib import Path
import tempfile

import f3d


def test_compare_with_file():
    testing_dir = Path(__file__).parent.parent.parent / "testing"
    dataset = testing_dir / "data/cow.vtp"
    reference = testing_dir / "baselines/TestPythonCompareWithFile.png"
    output = Path(tempfile.gettempdir()) / "TestPythonCompareWithFile.png"

    engine = f3d.Engine.create(True)
    engine.window.size = 300, 300

    # verify the size is properly set
    assert engine.window.width == 300
    assert engine.window.height == 300

    engine.scene.add(dataset)

    img = engine.window.render_to_image()
    img.save(output)

    assert img.compare(f3d.Image(reference)) <= 0.05