bpo-44514: Add doctest testcleanup for configparser and bz2 (GH-26909) (GH-27112)
Add testcleanup section to configparser and bz2 documentation which
removes temporary files created in the filesystem when 'make doctest'
is run.
(cherry picked from commit 48a5aa7f128caf5a46e4326c1fd285cd5fc8e59d)
Co-authored-by: Kevin Follstad <kfollstad@gmail.com>
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst
index f6787ab..999892e 100644
--- a/Doc/library/bz2.rst
+++ b/Doc/library/bz2.rst
@@ -325,3 +325,8 @@
... content = f.read()
>>> content == data # Check equality to original object after round-trip
True
+
+.. testcleanup::
+
+ import os
+ os.remove("myfile.bz2")
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index b0c2a2c..2bb4259 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -46,6 +46,11 @@
import configparser
+.. testcleanup::
+
+ import os
+ os.remove("example.ini")
+
Quick Start
-----------