Skip to content

Commit

Permalink
Remove need for nuking in_stream in basic run() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Aug 6, 2023
1 parent e83d660 commit fc25ee0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@

from fabric import Connection
from fabric.testing.base import MockRemote
from pytest import raises
from pytest import raises, fixture


@fixture(autouse=True)
def no_stdin():
# Just neuter primary stdin read (making it return real bytes tho)
with patch("fabric.runners.Remote.read_our_stdin", return_value=b""):
yield


class MockRemote_:
Expand All @@ -23,7 +30,7 @@ class mocks_by_default:
def prevents_real_ssh_connectivity_via_paramiko_guts(self, socket):
with MockRemote():
cxn = Connection(host="host")
cxn.run("nope", in_stream=False)
cxn.run("nope")
# High level mock...
assert isinstance(cxn.client, Mock)
# ...prevented low level connectivity (would have been at least
Expand Down Expand Up @@ -58,7 +65,7 @@ def does_not_break_ssh_mocking(self):
with MockRemote(enable_sftp=True) as mr:
mr.expect(cmd="whoami")
cxn = Connection(host="whatevs")
cxn.run("whoami", in_stream=False)
cxn.run("whoami")
# Safety: can call sftp stuff w/o expect()ing it, should noop
# instead of exploding
cxn.put("whatevs")
Expand All @@ -76,7 +83,7 @@ def enables_per_session_sftp_mocks(self):
],
)
cxn = Connection(host="host")
cxn.run("rm file", in_stream=False)
cxn.run("rm file")
cxn.put("whatevs")

def safety_checks_work(self):
Expand All @@ -94,6 +101,6 @@ def safety_checks_work(self):
cxn = Connection(host="host")
# Satisfy the less rigorous default expectations for
# commands
cxn.run("rm file", in_stream=False)
cxn.run("rm file")
# Oh no! The wrong put()!
cxn.put("onoz")

0 comments on commit fc25ee0

Please sign in to comment.