This is an automated email from the ASF dual-hosted git repository.
taragolis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 14e1b4c9c9 fix `PT012` in ssh (#38508)
14e1b4c9c9 is described below
commit 14e1b4c9c94d23d470956856291feeac0ed357a6
Author: rom sharon <[email protected]>
AuthorDate: Tue Mar 26 21:27:44 2024 +0200
fix `PT012` in ssh (#38508)
---
pyproject.toml | 2 --
tests/providers/ssh/hooks/test_ssh.py | 28 +++++++++++++---------------
tests/providers/ssh/operators/test_ssh.py | 3 +--
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 332a423160..399886431a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -412,8 +412,6 @@ combine-as-imports = true
"tests/providers/sftp/operators/test_sftp.py" = ["PT012"]
"tests/providers/sftp/sensors/test_sftp.py" = ["PT012"]
"tests/providers/sftp/triggers/test_sftp.py" = ["PT012"]
-"tests/providers/ssh/hooks/test_ssh.py" = ["PT012"]
-"tests/providers/ssh/operators/test_ssh.py" = ["PT012"]
[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
diff --git a/tests/providers/ssh/hooks/test_ssh.py
b/tests/providers/ssh/hooks/test_ssh.py
index 2adbf0cce1..3e0df8825d 100644
--- a/tests/providers/ssh/hooks/test_ssh.py
+++ b/tests/providers/ssh/hooks/test_ssh.py
@@ -941,22 +941,20 @@ class TestSSHHook:
session.commit()
def test_oneline_key(self):
+ TEST_ONELINE_KEY = "-----BEGIN OPENSSHPRIVATE KEY-----asdfg-----END
OPENSSHPRIVATE KEY-----"
+ session = settings.Session()
+ conn = Connection(
+ conn_id="openssh_pkey",
+ host="localhost",
+ conn_type="ssh",
+ extra={"private_key": TEST_ONELINE_KEY},
+ )
+ session.add(conn)
+ session.flush()
with pytest.raises(Exception):
- TEST_ONELINE_KEY = "-----BEGIN OPENSSHPRIVATE
KEY-----asdfg-----END OPENSSHPRIVATE KEY-----"
- session = settings.Session()
- try:
- conn = Connection(
- conn_id="openssh_pkey",
- host="localhost",
- conn_type="ssh",
- extra={"private_key": TEST_ONELINE_KEY},
- )
- session.add(conn)
- session.flush()
- SSHHook(ssh_conn_id=conn.conn_id)
- finally:
- session.delete(conn)
- session.commit()
+ SSHHook(ssh_conn_id=conn.conn_id)
+ session.delete(conn)
+ session.commit()
@pytest.mark.flaky(reruns=5)
def test_exec_ssh_client_command(self):
diff --git a/tests/providers/ssh/operators/test_ssh.py
b/tests/providers/ssh/operators/test_ssh.py
index 0cb42544ba..e9d8c8b543 100644
--- a/tests/providers/ssh/operators/test_ssh.py
+++ b/tests/providers/ssh/operators/test_ssh.py
@@ -167,11 +167,10 @@ class TestSSHOperator:
AirflowException, match="SSH operator error: SSH command not
specified. Aborting."
):
SSHOperator(
- task_id="test_4",
+ task_id="test_5",
ssh_hook=self.hook,
command=None,
).execute(None)
- task_0.execute(None)
@pytest.mark.parametrize(
"command, get_pty_in, get_pty_out",