Skip to content

Commit

Permalink
Handle both ops 2.15+ and ops 2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Sep 13, 2024
1 parent 16137ca commit 6686bb5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license.text = "Apache-2.0"
keywords = ["juju", "test"]

dependencies = [
"ops~=2.17",
"ops~=2.15",
"PyYAML>=6.0.1",
]
readme = "README.md"
Expand Down
7 changes: 5 additions & 2 deletions scenario/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
)

if TYPE_CHECKING: # pragma: no cover
from ops._private.harness import ExecArgs
try:
from ops._private.harness import ExecArgs # type: ignore
except ImportError:
from ops.testing import ExecArgs # type: ignore

from scenario.ops_main_mock import Ops
from scenario.state import (
Expand Down Expand Up @@ -499,7 +502,7 @@ def __init__(
self.charm_root = charm_root
self.juju_version = juju_version
if juju_version.split(".")[0] == "2":
logger.warn(
logger.warning(
"Juju 2.x is closed and unsupported. You may encounter inconsistencies.",
)

Expand Down
7 changes: 6 additions & 1 deletion scenario/mocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
)

from ops import JujuVersion, pebble
from ops._private.harness import ExecArgs, _TestingPebbleClient

try:
from ops._private.harness import ExecArgs, _TestingPebbleClient # type: ignore
except ImportError:
from ops.testing import ExecArgs, _TestingPebbleClient # type: ignore

from ops.model import CloudSpec as CloudSpec_Ops
from ops.model import ModelError
from ops.model import Port as Port_Ops
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands =
description = Static typing checks.
skip_install = true
deps =
ops~=2.17
ops~=2.15
pyright==1.1.347
commands =
pyright scenario
Expand Down

0 comments on commit 6686bb5

Please sign in to comment.