diff options
author | rsiddharth <s@ricketyspace.net> | 2020-07-11 18:22:23 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-07-11 18:22:23 -0400 |
commit | 7dbd4633d37f0976b6074fe89111d4c143d4fbfe (patch) | |
tree | 7ef37d0ee04df83b0913352808eb470a5f835b06 /tests | |
parent | 8e19751d14f5f3cf17094631e210ed4bef2c2f7f (diff) |
use black for formatting
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_markdown_link_style/test_logging.py | 23 | ||||
-rw-r--r-- | tests/test_mdl_style.py | 160 |
2 files changed, 85 insertions, 98 deletions
diff --git a/tests/test_markdown_link_style/test_logging.py b/tests/test_markdown_link_style/test_logging.py index d4aea87..1ce8c07 100644 --- a/tests/test_markdown_link_style/test_logging.py +++ b/tests/test_markdown_link_style/test_logging.py @@ -24,6 +24,7 @@ from io import StringIO from markdown_link_style.logging import MDLSLogger + class TestMDLSLogger(object): """Test class for markdown_link_style.logging.MDLSLogger. @@ -31,32 +32,32 @@ class TestMDLSLogger(object): def setup(self): self.stream = StringIO() - self.logger = MDLSLogger('TestLogger', self.stream) + self.logger = MDLSLogger("TestLogger", self.stream) def test_debug(self): - log_msg = 'DEBUG::MSG' + log_msg = "DEBUG::MSG" self.logger.debug(log_msg) - assert self.stream.getvalue().strip('\n') == log_msg + assert self.stream.getvalue().strip("\n") == log_msg def test_info(self): - log_msg = 'DEBUG::INFO' + log_msg = "DEBUG::INFO" self.logger.info(log_msg) - assert self.stream.getvalue().strip('\n') == log_msg + assert self.stream.getvalue().strip("\n") == log_msg def test_warning(self): - log_msg = 'DEBUG::WARNING' + log_msg = "DEBUG::WARNING" self.logger.warning(log_msg) - assert self.stream.getvalue().strip('\n') == log_msg + assert self.stream.getvalue().strip("\n") == log_msg def test_error(self): - log_msg = 'DEBUG::ERROR' + log_msg = "DEBUG::ERROR" self.logger.error(log_msg) - assert self.stream.getvalue().strip('\n') == log_msg + assert self.stream.getvalue().strip("\n") == log_msg def test_critical(self): - log_msg = 'DEBUG::CRITICAL' + log_msg = "DEBUG::CRITICAL" self.logger.critical(log_msg) - assert self.stream.getvalue().strip('\n') == log_msg + assert self.stream.getvalue().strip("\n") == log_msg def teardown(self): pass diff --git a/tests/test_mdl_style.py b/tests/test_mdl_style.py index 23372fd..a593240 100644 --- a/tests/test_mdl_style.py +++ b/tests/test_mdl_style.py @@ -37,12 +37,15 @@ from markdown_link_style._version import __version__ from mdl_style import * from mdl_style import _get_args, _mdl_stylize + def _get_data(f): - rs = resource_string(__name__, '/'.join(['data', f])) + rs = resource_string(__name__, "/".join(["data", f])) return rs.decode() + def _get_data_path(f): - return resource_filename(__name__, '/'.join(['data', f])) + return resource_filename(__name__, "/".join(["data", f])) + class TestLSRendererIL(object): """Test class for mdl_style.LSRenderer inline link style. @@ -50,59 +53,58 @@ class TestLSRendererIL(object): """ def setup(self): - self.md = LSMarkdown(link_style='inline') + self.md = LSMarkdown(link_style="inline") def test_autolink_00(self): - d = _get_data('autolink_00.md') - d_expected = _get_data('autolink_00-expected.md') + d = _get_data("autolink_00.md") + d_expected = _get_data("autolink_00-expected.md") assert_equals(self.md(d), d_expected) def test_link_footnote_to_inline_style_conversion_00(self): - d = _get_data('inline_link_style_00.md') - expected_result = _get_data('inline_link_style_00-expected.md') + d = _get_data("inline_link_style_00.md") + expected_result = _get_data("inline_link_style_00-expected.md") assert_equal(self.md(d), expected_result) def test_link_footnote_to_inline_style_conversion_01(self): - d = _get_data('inline_link_style_01.md') - expected_result = _get_data('inline_link_style_01-expected.md') + d = _get_data("inline_link_style_01.md") + expected_result = _get_data("inline_link_style_01-expected.md") assert_equal(self.md(d), expected_result) def test_renderer_parses_images_00(self): - d = _get_data('inline_parses_images_00.md') - expected_result = _get_data( - 'inline_parses_images_00-expected.md') + d = _get_data("inline_parses_images_00.md") + expected_result = _get_data("inline_parses_images_00-expected.md") assert_equal(self.md(d), expected_result) def test_renderer_does_not_parse_link_breaks_00(self): - d = _get_data('does_not_parse_link_breaks_00.md') + d = _get_data("does_not_parse_link_breaks_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_headers_00(self): - d = _get_data('does_not_parse_headers_00.md') + d = _get_data("does_not_parse_headers_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_blockquotes_00(self): - d = _get_data('does_not_parse_blockquotes_00.md') + d = _get_data("does_not_parse_blockquotes_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_lists_00(self): - d = _get_data('does_not_parse_lists_00.md') + d = _get_data("does_not_parse_lists_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_codeblocks_00(self): - d = _get_data('does_not_parse_codeblocks_00.md') + d = _get_data("does_not_parse_codeblocks_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_hrules_00(self): - d = _get_data('does_not_parse_hrules_00.md') + d = _get_data("does_not_parse_hrules_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_emphasis_00(self): - d = _get_data('does_not_parse_emphasis_00.md') + d = _get_data("does_not_parse_emphasis_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_code_00(self): - d = _get_data('does_not_parse_code_00.md') + d = _get_data("does_not_parse_code_00.md") assert_equal(self.md(d), d) def teardown(self): @@ -115,61 +117,58 @@ class TestLSRendererFN(object): """ def setup(self): - self.md = LSMarkdown(link_style='footnote') + self.md = LSMarkdown(link_style="footnote") def test_autolink_00(self): - d = _get_data('autolink_00.md') - d_expected = _get_data('autolink_00-expected.md') + d = _get_data("autolink_00.md") + d_expected = _get_data("autolink_00-expected.md") assert_equals(self.md(d), d_expected) def test_link_inline_to_footnote_style_conversion_00(self): - d = _get_data('footnote_link_style_00.md') - expected_result = _get_data( - 'footnote_link_style_00-expected.md') + d = _get_data("footnote_link_style_00.md") + expected_result = _get_data("footnote_link_style_00-expected.md") assert_equal(self.md(d), expected_result) def test_link_inline_to_footnote_style_conversion_01(self): - d = _get_data('footnote_link_style_01.md') - expected_result = _get_data( - 'footnote_link_style_01-expected.md') + d = _get_data("footnote_link_style_01.md") + expected_result = _get_data("footnote_link_style_01-expected.md") assert_equal(self.md(d), expected_result) def test_renderer_parses_images_00(self): - d = _get_data('footnote_parses_images_00.md') - expected_result = _get_data( - 'footnote_parses_images_00-expected.md') + d = _get_data("footnote_parses_images_00.md") + expected_result = _get_data("footnote_parses_images_00-expected.md") assert_equal(self.md(d), expected_result) def test_renderer_does_not_parse_link_breaks_00(self): - d = _get_data('does_not_parse_link_breaks_00.md') + d = _get_data("does_not_parse_link_breaks_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_headers_00(self): - d = _get_data('does_not_parse_headers_00.md') + d = _get_data("does_not_parse_headers_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_blockquotes_00(self): - d = _get_data('does_not_parse_blockquotes_00.md') + d = _get_data("does_not_parse_blockquotes_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_lists_00(self): - d = _get_data('does_not_parse_lists_00.md') + d = _get_data("does_not_parse_lists_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_codeblocks_00(self): - d = _get_data('does_not_parse_codeblocks_00.md') + d = _get_data("does_not_parse_codeblocks_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_hrules_00(self): - d = _get_data('does_not_parse_hrules_00.md') + d = _get_data("does_not_parse_hrules_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_emphasis_00(self): - d = _get_data('does_not_parse_emphasis_00.md') + d = _get_data("does_not_parse_emphasis_00.md") assert_equal(self.md(d), d) def test_renderer_does_not_parse_code_00(self): - d = _get_data('does_not_parse_code_00.md') + d = _get_data("does_not_parse_code_00.md") assert_equal(self.md(d), d) def teardown(self): @@ -185,46 +184,38 @@ class TestMdlStyleMdlStylize(object): def setup_class(self): self.test_data = {} - self.test_data['inline'] = {} - self.test_data['inline']['in'] = _get_data( - 'inline_link_style_00.md') - self.test_data['inline']['out'] = _get_data( - 'inline_link_style_00-expected.md') - - self.test_data['footnote'] = {} - self.test_data['footnote']['in'] = _get_data( - 'footnote_link_style_00.md') - self.test_data['footnote']['out'] = _get_data( - 'footnote_link_style_00-expected.md') + self.test_data["inline"] = {} + self.test_data["inline"]["in"] = _get_data("inline_link_style_00.md") + self.test_data["inline"]["out"] = _get_data("inline_link_style_00-expected.md") - self.in_file = 'in_file.md' - self.out_file = 'out_file.md' + self.test_data["footnote"] = {} + self.test_data["footnote"]["in"] = _get_data("footnote_link_style_00.md") + self.test_data["footnote"]["out"] = _get_data( + "footnote_link_style_00-expected.md" + ) + self.in_file = "in_file.md" + self.out_file = "out_file.md" def setup(self): - self.link_style = ['inline', 'footnote'][randint(0, 1)] - - with open(self.in_file, 'w') as f: - f.write(self.test_data[self.link_style]['in']) + self.link_style = ["inline", "footnote"][randint(0, 1)] + with open(self.in_file, "w") as f: + f.write(self.test_data[self.link_style]["in"]) def test_mdl_stylize_infile(self): args = _get_args([self.link_style, self.in_file]) - _mdl_stylize(args) # the test. - - with open(self.in_file, 'r') as f: - assert_equal(f.read(), - self.test_data[self.link_style]['out']) + _mdl_stylize(args) # the test. + with open(self.in_file, "r") as f: + assert_equal(f.read(), self.test_data[self.link_style]["out"]) def test_mdl_stylize_infile_outfile(self): args = _get_args([self.link_style, self.in_file, self.out_file]) _mdl_stylize(args) - with open(self.out_file, 'r') as f: - assert_equal(f.read(), - self.test_data[self.link_style]['out']) - + with open(self.out_file, "r") as f: + assert_equal(f.read(), self.test_data[self.link_style]["out"]) def teardown(self): if os.path.isfile(self.in_file): @@ -242,58 +233,53 @@ class TestMdlStyleGetArgs(object): def setup(self): self.out = None - @raises(SystemExit) def test_get_args_version(self): real_exit = sys.exit + def mock_exit(args): - assert_equal(sys.stdout.getvalue(), - __version__ + '\n') + assert_equal(sys.stdout.getvalue(), __version__ + "\n") real_exit(args) - with mock.patch('sys.stdout', new_callable=StringIO) as out, \ - mock.patch('sys.exit', new=mock_exit): - raw_args = ['--version'] + with mock.patch("sys.stdout", new_callable=StringIO) as out, mock.patch( + "sys.exit", new=mock_exit + ): + raw_args = ["--version"] _get_args(raw_args) - def test_get_args_inline_infile(self): - lstyle = 'inline' - md_file = 'autolink_00.md' + lstyle = "inline" + md_file = "autolink_00.md" raw_args = [lstyle, _get_data_path(md_file)] args = _get_args(raw_args) assert_equal(args.link_style, lstyle) assert_equal(args.in_file.read(), _get_data(md_file)) - def test_get_args_inline_infile_outfile(self): - lstyle = 'inline' - md_file = 'autolink_00.md' - raw_args = [lstyle, _get_data_path(md_file), 'outfile.md'] + lstyle = "inline" + md_file = "autolink_00.md" + raw_args = [lstyle, _get_data_path(md_file), "outfile.md"] args = _get_args(raw_args) assert_equal(args.link_style, lstyle) assert_equal(args.in_file.read(), _get_data(md_file)) assert_equal(type(args.out_file), str) - def test_get_args_footnote_infile(self): - lstyle = 'footnote' - md_file = 'autolink_00.md' + lstyle = "footnote" + md_file = "autolink_00.md" raw_args = [lstyle, _get_data_path(md_file)] args = _get_args(raw_args) assert_equal(args.link_style, lstyle) assert_equal(args.in_file.read(), _get_data(md_file)) - def test_get_args_footnote_infile_outfile(self): - lstyle = 'footnote' - md_file = 'autolink_00.md' - raw_args = [lstyle, _get_data_path(md_file), 'outfile.md'] + lstyle = "footnote" + md_file = "autolink_00.md" + raw_args = [lstyle, _get_data_path(md_file), "outfile.md"] args = _get_args(raw_args) assert_equal(args.link_style, lstyle) assert_equal(args.in_file.read(), _get_data(md_file)) assert_equal(type(args.out_file), str) - def teardown(self): pass |