Starting to write some simple op tests in pytest a...
# ask-community
s
Starting to write some simple op tests in pytest and ran across a strange issue. When an op requires context and the test fails, I get a subsequent failure from dagster:
Copy code
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Turns out I don’t need the op or anything, just have to build a context. Here’s the code `test_dummy.py`:
Copy code
from dagster import build_op_context

def test_dummy_op():
    context = build_op_context(resources={"FAVORITE_PIE": "Key Lime", "LEAST_FAVORITE_PIE": "Lack of"})
    assert False
I see that this was originally reported last year, but they said it stopped when they moved from solids to ops, but that’s not the case here. If I use a context manager
with build_op_context(…) as context:
, I don’t have the issue but it’s not clear whether that’s the expected testing pattern or not. I’m using dagster 1.0.3 and pytest 7.1.2
c
Hi Sterling. Thanks for reporting this issue, I was able to replicate this. I think its reasonable to use this function outside of a context manager. I'll file an issue for this so we can track this. For now, it might be easiest to work around this by using the function as a context manager.
@Dagster Bot issue assertion causes error when build_op_context not used as context manager
d
s
Thanks, and nice bot!
🌈 1