Skip to content

Commit

Permalink
test properties (#107)
Browse files Browse the repository at this point in the history
* test `functools.cached_property`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PythonFZ and pre-commit-ci[bot] authored Aug 29, 2024
1 parent 74b1cd3 commit fb8eeb5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_edgecases.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import functools

import pytest

import znflow


Expand All @@ -12,6 +16,13 @@ def result(self):
raise TypeError("This value is not available until the node is run.")


class NodeCachedProperty(znflow.Node):

@functools.cached_property
def result(self):
raise TypeError("This value is not available until the node is run.")


class ConnectResults(znflow.Node):
@property
def result(self):
Expand All @@ -33,6 +44,20 @@ def test_PlainNode():

assert isinstance(con, znflow.Connection)

with pytest.raises(TypeError):
con.result


def test_NodeCachedProperty():
with znflow.DiGraph():
node1 = NodeCachedProperty()
con = node1.result

assert isinstance(con, znflow.Connection)

with pytest.raises(TypeError):
con.result


def test_ConnectResults():
with znflow.DiGraph() as graph:
Expand Down

0 comments on commit fb8eeb5

Please sign in to comment.