diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-04 13:02:29 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-04 13:02:29 -0500 |
| commit | 9ecca93a9b400c20af613cbb71d3d531ce8c7d5a (patch) | |
| tree | 82a7fd4fd2b74dccc1f9c7054344c50ba33feed2 /tests | |
| parent | d4777150640e21ac222c559a660e6a3c8c27a031 (diff) | |
| download | flake8-9ecca93a9b400c20af613cbb71d3d531ce8c7d5a.tar.gz | |
Add more BaseFormatter subclass tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_base_formatter.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/unit/test_base_formatter.py b/tests/unit/test_base_formatter.py index 5422aec..a23a9cb 100644 --- a/tests/unit/test_base_formatter.py +++ b/tests/unit/test_base_formatter.py @@ -114,5 +114,31 @@ class AfterInitFormatter(base.BaseFormatter): def test_after_init_is_always_called(): """Verify after_init is called.""" - formatter = AfterInitFormatter() + formatter = AfterInitFormatter(options()) assert getattr(formatter, 'post_initialized') is True + + +class FormatFormatter(base.BaseFormatter): + """Subclass for testing format.""" + + def format(self, error): + """Define method to verify operation.""" + return repr(error) + + +def test_handle_formats_the_error(): + """Verify that a formatter will call format from handle.""" + formatter = FormatFormatter(options(show_source=False)) + filemock = formatter.output_fd = mock.Mock() + error = style_guide.Error( + code='A001', + filename='example.py', + line_number=1, + column_number=1, + text='Fake error', + physical_line='a = 1', + ) + + formatter.handle(error) + + filemock.write.assert_called_once_with(repr(error) + '\n') |
