Skip to content

It should be an error to @patch a function that isn't @mocked. Currently it is silently ignored. #140

@NHDaly

Description

@NHDaly

I was recently debugging a test that accidentally patched the wrong function. (The mocked function was the patched function's callee.)

Instead of getting an error, as I'd expect, to protect the programmer from the mistake the test silently passed, even though actually the test would have been broken if the patch was on the correct function. This is quite bad, and should be fixed.

Here is a simple example. I would expect this to throw an error on the @patch call, rather than proceeding:

julia> foo() = 10
foo (generic function with 1 method)

julia> apply(@patch foo() = 3) do
           @show foo()
       end
foo() = 10
10

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions