diff --git a/.gitignore b/.gitignore index 1ea1781..202bedb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ *.egg-info __pycache__ /dist/ -/coverage.json -/coverage.xml +/coverage.* !.github !.editorconfig !.flake8 !.gitignore +!.gitkeep diff --git a/README.md b/README.md index 3814f5b..6109b7c 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ Assert complex output via auto updated snapshot files with nice diff error messa #### bx_py_utils.test_utils.unittest_utils -* [`BaseDocTests()`](https://github.com/boxine/bx_py_utils/blob/master/bx_py_utils/test_utils/unittest_utils.py#L40-L87) - Helper to include all doctests in unittests, without change unittest setup. Just add a normal TestCase. +* [`BaseDocTests()`](https://github.com/boxine/bx_py_utils/blob/master/bx_py_utils/test_utils/unittest_utils.py#L40-L91) - Helper to include all doctests in unittests, without change unittest setup. Just add a normal TestCase. * [`assert_no_flat_tests_functions()`](https://github.com/boxine/bx_py_utils/blob/master/bx_py_utils/test_utils/unittest_utils.py#L16-L30) - Check if there exists normal test functions (That will not be executed by normal unittests) ### bx_py_utils.text_tools diff --git a/bx_py_utils/doc_write/README.md b/bx_py_utils/doc_write/README.md index 6e28af8..f37bd9f 100644 --- a/bx_py_utils/doc_write/README.md +++ b/bx_py_utils/doc_write/README.md @@ -66,11 +66,11 @@ Notes: ### Notes -* The created created Markdown file is relative to `output_base_path` (defined in `pyproject.toml`) - -* Headlines will be sorted, so they appears ordered by the level. - * All Doc-String without the `{prefix}` will be ignored. * The `{file-path}` must has the file extension `.md` -Otherwise the DocString block will be ignored. \ No newline at end of file +Otherwise the DocString block will be ignored. + +* The created created Markdown file is relative to `output_base_path` (defined in `pyproject.toml`) + +* Headlines will be sorted, so they appears ordered by the level. \ No newline at end of file diff --git a/bx_py_utils/html_utils.py b/bx_py_utils/html_utils.py index 74fd054..c01a668 100644 --- a/bx_py_utils/html_utils.py +++ b/bx_py_utils/html_utils.py @@ -89,7 +89,7 @@ def pretty_format_html(data, parser='html.parser', **bs_kwargs): Pretty format given HTML document via BeautifulSoup (Needs 'beautifulsoup4' package) """ soup = get_beautiful_soup_instance(data, parser, **bs_kwargs) - return soup.prettify() + return soup.prettify().rstrip() def get_html_elements(data, query_selector, parser='html.parser', **bs_kwargs): diff --git a/bx_py_utils/test_utils/unittest_utils.py b/bx_py_utils/test_utils/unittest_utils.py index 1e2ea03..f07bb33 100644 --- a/bx_py_utils/test_utils/unittest_utils.py +++ b/bx_py_utils/test_utils/unittest_utils.py @@ -63,8 +63,12 @@ def run_doctests( for module in modules: self.assertTrue(inspect.ismodule(module), f'Not a module: {module}') - for info in pkgutil.walk_packages(module.__path__, module.__name__ + '.'): + module_finder = info.module_finder + module_path = module_finder.path + if filename_matcher(patterns=excludes, file_path=module_path): + continue + module = importlib.import_module(info.name) tests: list[doctest.DocTest] = finder.find(obj=module) for test in tests: diff --git a/bx_py_utils_tests/publish.py b/bx_py_utils_tests/publish.py index 57dce96..ac9d6d2 100644 --- a/bx_py_utils_tests/publish.py +++ b/bx_py_utils_tests/publish.py @@ -4,8 +4,8 @@ from pathlib import Path +from cli_base.cli_tools.subprocess_utils import verbose_check_call from manageprojects.utilities.publish import publish_package -from manageprojects.utilities.subprocess_utils import verbose_check_call import bx_py_utils diff --git a/bx_py_utils_tests/tests/test_html_utils.py b/bx_py_utils_tests/tests/test_html_utils.py index 1ae3163..d362c2b 100644 --- a/bx_py_utils_tests/tests/test_html_utils.py +++ b/bx_py_utils_tests/tests/test_html_utils.py @@ -62,7 +62,7 @@ def test_validate_html(self): ) def test_pretty_format_html(self): - assert pretty_format_html('
Test
') == '\n Test\n
' + self.assertEqual(pretty_format_html('Test
'), '\n Test\n
') html = pretty_format_html( ''' @@ -70,14 +70,16 @@ def test_pretty_format_html(self):Test
\r\n \r\n ''' ) - assert html == '\n \n Test\n \n
\n' + self.assertEqual(html, '\n \n Test\n \n
') - assert pretty_format_html("<script>alert('XSS')</script>
") == (
- '\n' " <script>alert('XSS')</script>\n" '
'
+ self.assertEqual(
+ pretty_format_html("<script>alert('XSS')</script>
"),
+ ('\n' " <script>alert('XSS')</script>\n" '
'),
)
- assert pretty_format_html('<XSS énc🕳d👁ng> aaa
') == ( - '\n <XSS énc🕳d👁ng> aaa\n
' + self.assertEqual( + pretty_format_html('<XSS énc🕳d👁ng> aaa
'), + ('\n <XSS énc🕳d👁ng> aaa\n
'), ) # Our helpful error message if requirements missing? diff --git a/bx_py_utils_tests/tests/test_test_utils_snapshot_assert_html_snapshot_1.snapshot.html b/bx_py_utils_tests/tests/test_test_utils_snapshot_assert_html_snapshot_1.snapshot.html index 3d12e7e..fd56e91 100644 --- a/bx_py_utils_tests/tests/test_test_utils_snapshot_assert_html_snapshot_1.snapshot.html +++ b/bx_py_utils_tests/tests/test_test_utils_snapshot_assert_html_snapshot_1.snapshot.html @@ -13,4 +13,4 @@