Skip to content

Commit

Permalink
add tests for print steps
Browse files Browse the repository at this point in the history
  • Loading branch information
boucherlfg committed Feb 1, 2025
1 parent e90d55f commit 44e12cd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_printing_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest
from unittest.mock import patch
from pennylane_calculquebec.processing.steps.print_steps import PrintResults, PrintTape

class Tape:
def __init__(self, ops):
self.operations = ops


class Op:
def __init__(self):
pass


@pytest.fixture
def mock_print():
with patch("builtins.print") as mock:
yield mock


def test_print_tape(mock_print):
step = PrintTape()
tape = Tape(ops=[Op(), Op(), Op()])

new_tape = step.execute(tape)

assert tape is new_tape
mock_print.assert_called_once()

def test_print_results(mock_print):
step = PrintResults()
tape = Tape(ops=[Op(), Op(), Op()])
results = {"0" : 0, "1" : 1, "2" : 2}

new_results = step.execute(tape, results)
assert results is new_results
mock_print.assert_called_once()

0 comments on commit 44e12cd

Please sign in to comment.