~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-03 16:45:53 UTC
  • mfrom: (4248.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20090403164553-wo2n7k4nvd1xcyw3
(vila) Stop requiring a controlling terminal to query for passwords

Show diffs side-by-side

added added

removed removed

Lines of Context:
675
675
    Allows get_password to be tested without real tty attached.
676
676
    """
677
677
 
678
 
    def __init__(self,
679
 
                 stdout=None,
680
 
                 stderr=None,
681
 
                 stdin=None):
682
 
        super(TestUIFactory, self).__init__()
 
678
    def __init__(self, stdout=None, stderr=None, stdin=None):
683
679
        if stdin is not None:
684
680
            # We use a StringIOWrapper to be able to test various
685
681
            # encodings, but the user is still responsible to
686
682
            # encode the string and to set the encoding attribute
687
683
            # of StringIOWrapper.
688
 
            self.stdin = StringIOWrapper(stdin)
689
 
        if stdout is None:
690
 
            self.stdout = sys.stdout
691
 
        else:
692
 
            self.stdout = stdout
693
 
        if stderr is None:
694
 
            self.stderr = sys.stderr
695
 
        else:
696
 
            self.stderr = stderr
 
684
            stdin = StringIOWrapper(stdin)
 
685
        super(TestUIFactory, self).__init__(stdin, stdout, stderr)
697
686
 
698
687
    def clear(self):
699
688
        """See progress.ProgressBar.clear()."""
701
690
    def clear_term(self):
702
691
        """See progress.ProgressBar.clear_term()."""
703
692
 
704
 
    def clear_term(self):
705
 
        """See progress.ProgressBar.clear_term()."""
706
 
 
707
693
    def finished(self):
708
694
        """See progress.ProgressBar.finished()."""
709
695
 
720
706
    def update(self, message, count=None, total=None):
721
707
        """See progress.ProgressBar.update()."""
722
708
 
723
 
    def get_non_echoed_password(self, prompt):
 
709
    def get_non_echoed_password(self):
724
710
        """Get password from stdin without trying to handle the echo mode"""
725
 
        if prompt:
726
 
            self.stdout.write(prompt.encode(self.stdout.encoding, 'replace'))
727
711
        password = self.stdin.readline()
728
712
        if not password:
729
713
            raise EOFError