~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

(vila) Allows bzr shelve to be used in test scripts and under emacs shells
 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
572
572
    def test_confirm_action(self):
573
573
        """You can write tests that demonstrate user confirmation.
574
574
        
575
 
        Specifically, ScriptRunner does't care if the output line for the prompt
576
 
        isn't terminated by a newline from the program; it's implicitly terminated 
577
 
        by the input.
 
575
        Specifically, ScriptRunner does't care if the output line for the
 
576
        prompt isn't terminated by a newline from the program; it's implicitly
 
577
        terminated by the input.
578
578
        """
579
579
        commands.builtin_command_registry.register(cmd_test_confirm)
580
580
        self.addCleanup(commands.builtin_command_registry.remove, 'test-confirm')
589
589
            ok, no
590
590
            """)
591
591
 
 
592
class TestShelve(script.TestCaseWithTransportAndScript):
 
593
 
 
594
    def setUp(self):
 
595
        super(TestShelve, self).setUp()
 
596
        self.run_script("""
 
597
            $ bzr init test
 
598
            Created a standalone tree (format: 2a)
 
599
            $ cd test
 
600
            $ echo foo > file
 
601
            $ bzr add
 
602
            adding file
 
603
            $ bzr commit -m 'file added'
 
604
            2>Committing to:...test/
 
605
            2>added file
 
606
            2>Committed revision 1.
 
607
            $ echo bar > file
 
608
            """)
 
609
 
 
610
    def test_shelve(self):
 
611
        self.run_script("""
 
612
            $ bzr shelve -m 'shelve bar'
 
613
            # Shelve? [yNfq?]
 
614
            <y
 
615
            # Shelve 1 change(s)? [yNfq?]
 
616
            <y
 
617
            2>Selected changes:
 
618
            2> M  file
 
619
            2>Changes shelved with id "1".
 
620
            """,
 
621
                        # shelve uses \r that can't be represented in the
 
622
                        # script ?
 
623
                        null_output_matches_anything=True)
 
624
        self.run_script("""
 
625
            $ bzr shelve --list
 
626
              1: shelve bar
 
627
            """)
 
628
 
 
629
    def test_dont_shelve(self):
 
630
        # We intentionally provide no input here to test EOF
 
631
        self.run_script("""
 
632
            $ bzr shelve -m 'shelve bar'
 
633
            # Shelve? [yNfq?]
 
634
            # Shelve 1 change(s)? [yNfq?]
 
635
            2>No changes to shelve.
 
636
            """,
 
637
                        # shelve uses \r that can't be represented in the
 
638
                        # script ?
 
639
                        null_output_matches_anything=True)
 
640
        self.run_script("""
 
641
            $ bzr st
 
642
            modified:
 
643
              file
 
644
            """)