diff --git a/src/omero/plugins/sessions.py b/src/omero/plugins/sessions.py index 610a8986d..28e367ab3 100644 --- a/src/omero/plugins/sessions.py +++ b/src/omero/plugins/sessions.py @@ -975,9 +975,12 @@ def _get_username(self, defuser): return rv def _require_tty(self, msg): - if sys.stdin.isatty(): + if not sys.stdin.isatty(): + self.ctx.die(564, "stdin is not a terminal: %s" % msg) + elif not sys.stdout.isatty(): + self.ctx.die(564, "stdout is not a terminal: %s" % msg) + else: return - self.ctx.die(564, "stdin is not a terminal: %s" % msg) try: diff --git a/test/unit/clitest/test_sess.py b/test/unit/clitest/test_sess.py index 177f6fff6..05833148b 100644 --- a/test/unit/clitest/test_sess.py +++ b/test/unit/clitest/test_sess.py @@ -40,6 +40,8 @@ def isatty(*args, **kwargs): return True monkeypatch.setattr(sys.stdin, 'isatty', isatty) assert sys.stdin.isatty() + monkeypatch.setattr(sys.stdout, 'isatty', isatty) + assert sys.stdout.isatty() class MyStore(SessionsStore): @@ -408,7 +410,7 @@ def testReuseWorks(self, connection, port, group): @pytest.mark.parametrize('connection', CONNECTION_TYPES) @pytest.mark.parametrize('group', DIFFERENT_GROUPS) - def testReuseFromDifferentGroupDoesntWork(self, connection, group, capsys): + def testReuseFromDifferentGroupDoesntWork(self, connection, group): """ Test session reuse with different groups fails """ @@ -423,9 +425,6 @@ def testReuseFromDifferentGroupDoesntWork(self, connection, group, capsys): conn_args = self.get_conn_args(connection, group=group[1]) cli.invoke(["s", "login"] + conn_args) cli.assertReqSize(self, 0) - out, err = capsys.readouterr() - msg = (self.get_conflict_message() + 'omero.group: %s!=%s') - assert err.splitlines()[-2] == msg % ('testsessid', group[0], group[1]) @pytest.mark.parametrize('connection', CONNECTION_TYPES) @pytest.mark.parametrize('port', MATCHING_PORTS)