-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
activate
method taking function (#102)
* Add `activate` method taking function * Bump version * Combine docstrings per code review
- Loading branch information
1 parent
f07545f
commit 47abfea
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@testset "activate(func)" begin | ||
add1(x) = x + 1 | ||
patch = @patch add1(x) = x + 42 | ||
|
||
# Starting with Mocking enabled. | ||
Mocking.activate() | ||
@assert Mocking.activated() | ||
Mocking.activate() do | ||
apply(patch) do | ||
@test (@mock add1(2)) == 44 | ||
end | ||
end | ||
@test Mocking.activated() | ||
|
||
# Starting with Mocking disabled. | ||
# Make sure to leave it enabled for the rest of the tests. | ||
try | ||
Mocking.deactivate() | ||
@assert !Mocking.activated() | ||
Mocking.activate() do | ||
apply(patch) do | ||
@test (@mock add1(2)) == 44 | ||
end | ||
end | ||
@test !Mocking.activated() | ||
finally | ||
Mocking.activate() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47abfea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
47abfea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/78894
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: