Mocking.jl icon indicating copy to clipboard operation
Mocking.jl copied to clipboard

Allows Julia function calls to be temporarily overloaded for purpose of testing

Results 18 Mocking.jl issues
Sort by recently updated
recently updated
newest added

In julia 1.11 we get a proper way to do what ContextVariablesX did with an hack. This is a rebasing of #91 with that switch over it should not run...

[Adds support for the other kind of mocking to Mocking.jl](https://knowyourmeme.com/memes/mocking-spongebob)

```julia julia> using Mocking: @patch julia> f() = 5 f (generic function with 1 method) julia> f_patch = @patch f() = 6 ERROR: UndefVarError: Mocking not defined Stacktrace: [1] top-level...

runtests.jl ``` cd(@__DIR__) using Pkg using Test, TestSetExtensions, SafeTestsets @testset ExtendedTestSet "Example tests" begin @includetests ARGS end ``` test.jl ``` @safetestset "test" begin using Mocking Mocking.activate() patch = @patch open(fn::Function,...

Looking at this, https://github.com/invenia/Mocking.jl/blob/master/src/patch.jl#L138-L140 Would anybody be opposed to adding something like ```julia function apply(body::Function, patches...; debug::Bool=false) return apply(body, collect(patches); debug) end ``` This is mostly just a visual enhancement,...

enhancement

Added a new example for using the Mocking.jl package

In a scenario where an background asynchronous task is calling a function using `@mock` and a patch is applied during that time the async task can call the patched function...

```julia julia> using Mocking julia> struct A a end julia> @patch function (a::A)(b) 1 end ERROR: UndefVarError: a not defined Stacktrace: [1] top-level scope @ REPL[4]:1 ``` Note that ExprTools.jl...