From 4b5cb0034cc8f9ddd4ed1354ee06e74229221201 Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Tue, 4 Jun 2024 12:41:54 +0100 Subject: [PATCH] Guide to delete the build folder before testing --- CHANGES.rst | 1 + src/icalendar/tests/test_with_doctest.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 94833eba..5eec8fb3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Changelog Minor changes: +- Guide to delete the build folder before running tests - Add funding information - Update windows to olson conversion for Greenland Standard Time - Extend examples in Usage with alarm and recurrence diff --git a/src/icalendar/tests/test_with_doctest.py b/src/icalendar/tests/test_with_doctest.py index d536ff9c..b6513032 100644 --- a/src/icalendar/tests/test_with_doctest.py +++ b/src/icalendar/tests/test_with_doctest.py @@ -1,6 +1,6 @@ """This file tests the source code provided by the documentation. -See +See - doctest documentation: https://docs.python.org/3/library/doctest.html - Issue 443: https://github.com/collective/icalendar/issues/443 @@ -43,12 +43,15 @@ def test_docstring_of_python_file(module_name): # This collection needs to exclude .tox and other subdirectories DOCUMENTATION_PATH = os.path.join(HERE, "../../../") -DOCUMENT_PATHS = [ - os.path.join(DOCUMENTATION_PATH, subdir, filename) - for subdir in ["docs", "."] - for filename in os.listdir(os.path.join(DOCUMENTATION_PATH, subdir)) - if filename.lower().endswith(".rst") -] +try: + DOCUMENT_PATHS = [ + os.path.join(DOCUMENTATION_PATH, subdir, filename) + for subdir in ["docs", "."] + for filename in os.listdir(os.path.join(DOCUMENTATION_PATH, subdir)) + if filename.lower().endswith(".rst") + ] +except FileNotFoundError: + raise EnvironmentError("Could not find the documentation - remove the build folder and try again.") @pytest.mark.parametrize("filename", [ "README.rst", @@ -62,6 +65,3 @@ def test_documentation_file(document): """This test runs doctest on a documentation file.""" test_result = doctest.testfile(document, module_relative=False) assert test_result.failed == 0, f"{test_result.failed} errors in {os.path.basename(document)}" - - -