~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

Implement a 'cat' command.

* bzrlib/tests/test_script.py:
(TestCat): Test the 'cat' command.

* bzrlib/tests/script.py:
(TestCaseWithScript): TestCase that can run shell-like
scripts. Implement 'cat' to fill files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                          script._script_to_commands(story))
80
80
 
81
81
 
 
82
class TestScriptExecution(script.TestCaseWithScript):
 
83
 
 
84
    def test_unknown_command(self):
 
85
        self.assertRaises(SyntaxError, self.run_script, 'foo')
 
86
 
 
87
 
 
88
class TestCat(script.TestCaseWithScript):
 
89
 
 
90
    def test_cat_usage(self):
 
91
        self.assertRaises(SyntaxError, self.run_script, 'cat foo bar baz')
 
92
 
 
93
    def test_cat_input_to_output(self):
 
94
        out, err = self.run_command(['cat'], ['content\n'], ['content\n'], None)
 
95
 
 
96
    def test_cat_file_to_output(self):
 
97
        self.build_tree_contents([('file', 'content\n')])
 
98
        out, err = self.run_command(['cat', 'file'], None, ['content\n'], None)
 
99
 
 
100
    def test_cat_input_to_file(self):
 
101
        out, err = self.run_command(['cat', '>file'], ['content\n'], None, None)
 
102
        self.assertFileEqual('content\n', 'file')
 
103
 
 
104
    def test_cat_file_to_file(self):
 
105
        self.build_tree_contents([('file', 'content\n')])
 
106
        out, err = self.run_command(['cat', 'file', '>file2'], None, None, None)
 
107
        self.assertFileEqual('content\n', 'file2')