Hi guys! I am trying to test a composite_solid and...
# announcements
Hi guys! I am trying to test a composite_solid and mock a solid within it. I am using monkeypatch mechanism from pytest to replace the solid. However, it does not seem like the patch is working. Do you know how to solve the problem? A sample code is as follows:
Copy code
def test_my_test(monkeypatch):
    def mock_my_solid(_):
        yield Output(pd.DataFrame({
            "date": pd.to_datetime(["2020-05-01", datetime.today()]),
            "name": ["One", "Two"]

    monkeypatch.setattr("mymodule.my_solid", mock_my_solid)

    result = execute_solid(my_composite_solid_using_my_solid)
    out = result.output_for_solid("my_solid")  # This returns the original output from my_solid
composite solids are evaluated at init time so monkey patching after they are defined won’t work
Ah, okay, understood. Is there a way to mock solids within composites at all?
hmm not really if its defined at module scope - maybe make the composite solid an output of a function, then you can mock before you invoke the function
Cool. Thanks a lot, alex! This is helpful.