Common function to assert the behaviour of command line interface.
(self, *args, stdout="", stderr="", partial=False, expect_failure=False)
| 294 | """Tests command line interface of `tabnanny`.""" |
| 295 | |
| 296 | def validate_cmd(self, *args, stdout="", stderr="", partial=False, expect_failure=False): |
| 297 | """Common function to assert the behaviour of command line interface.""" |
| 298 | if expect_failure: |
| 299 | _, out, err = script_helper.assert_python_failure('-m', 'tabnanny', *args) |
| 300 | else: |
| 301 | _, out, err = script_helper.assert_python_ok('-m', 'tabnanny', *args) |
| 302 | # Note: The `splitlines()` will solve the problem of CRLF(\r) added |
| 303 | # by OS Windows. |
| 304 | out = os.fsdecode(out) |
| 305 | err = os.fsdecode(err) |
| 306 | if partial: |
| 307 | for std, output in ((stdout, out), (stderr, err)): |
| 308 | _output = output.splitlines() |
| 309 | for _std in std.splitlines(): |
| 310 | with self.subTest(std=_std, output=_output): |
| 311 | self.assertIn(_std, _output) |
| 312 | else: |
| 313 | self.assertListEqual(out.splitlines(), stdout.splitlines()) |
| 314 | self.assertListEqual(err.splitlines(), stderr.splitlines()) |
| 315 | |
| 316 | def test_with_errored_file(self): |
| 317 | """Should displays error when errored python file is given.""" |
no test coverage detected