-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use _JujuContext in Scenario (#1459)
Properly use the `ops.jujucontext._JujuContext` class in Scenario. When `_JujuContext` was introduced in ops, we added some quick compatibility code to Scenario that made use of it, but it was basically just recreating the context object from the environment everywhere. This PR tidies things up in two main ways: * Create a single `_JujuContext` object and pass it around where it's required. This also sets the stage for using the ops `_Manager` class in a later PR. * Rather than updating and then later (imprecisely) reverting `os.environ`, just pass the mock environment directly when creating the `_JujuContext` object. Note that to maintain backwards compatibility of public methods the argument is optional in some places and will fall back to the environment - this won't be exactly the same, since we aren't manipulating the environment any more, but the signatures are the same. I don't think it's worth jumping through the hoops to have it entirely the same behaviour (by having the fallback do environment patching). It seems unlikely anyone is actually using these, even though they are public (the only candidate I can think of is Catan, but that's pinned to 6.x). Perhaps, given that the *behaviour* ends up potentially changing (depending on how the caller is using things), it's not worth keeping the signatures the same? I'm interested in reviewer's opinions on this. --------- Co-authored-by: Ben Hoyt <[email protected]>
- Loading branch information
1 parent
c6a3b14
commit 42248cd
Showing
4 changed files
with
44 additions
and
49 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
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