]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38250: [Enum] only include .rst test if file available (GH-24342)
authorEthan Furman <ethan@stoneleaf.us>
Tue, 26 Jan 2021 20:52:52 +0000 (12:52 -0800)
committerGitHub <noreply@github.com>
Tue, 26 Jan 2021 20:52:52 +0000 (12:52 -0800)
* [Enum] only include .rst test if file available

In order to ensure the ReST documentation is up to date for Enum,
use doctest to check it -- but only if the .rst files have not
been stripped.

Lib/test/test_enum.py

index daca2e3c83f2711212b031e0f682430a65ce7a0b..96de878faf72d4127d971786592754f338f19c1a 100644 (file)
@@ -1,6 +1,7 @@
 import enum
 import doctest
 import inspect
+import os
 import pydoc
 import sys
 import unittest
@@ -17,10 +18,11 @@ from datetime import timedelta
 
 def load_tests(loader, tests, ignore):
     tests.addTests(doctest.DocTestSuite(enum))
-    tests.addTests(doctest.DocFileSuite(
-            '../../Doc/library/enum.rst',
-            optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
-            ))
+    if os.path.exists('../../Doc/library/enum.rst'):
+        tests.addTests(doctest.DocFileSuite(
+                '../../Doc/library/enum.rst',
+                optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
+                ))
     return tests
 
 # for pickle tests