/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-02 10:43:01 UTC
  • mto: (4248.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 4249.
  • Revision ID: v.ladeuil+lp@free.fr-20090402104301-esvcd0lcqru9g4lb
Stop requiring a tty for CLIUIFactory and derivatives.

* bzrlib/ui/text.py:
(TextUIFactory.prompt):  Deleted, not needed anymore.

* bzrlib/ui/__init__.py:
(CLIUIFactory.get_boolean): Delegate terminal handling to
prompt().
(CLIUIFactory.get_non_echoed_password): Simplified.
(CLIUIFactory.get_password): Delegate terminal handling to
prompt().
(CLIUIFactory.prompt): Clear the terminal, builb, encode and
displays the prompt.
(SilentUIFactory.prompt): Update signature.

* bzrlib/tests/__init__.py:
(TestUIFactory.__init__): Simplified.
(TestUIFactory.get_non_echoed_password): No need for prompt here.

* errors.py:
(NotATerminal): Deleted.

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