summaryrefslogtreecommitdiff
path: root/coverage/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/__init__.py')
-rw-r--r--coverage/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/coverage/__init__.py b/coverage/__init__.py
index c1b95874..c787b341 100644
--- a/coverage/__init__.py
+++ b/coverage/__init__.py
@@ -23,12 +23,20 @@ from coverage.misc import CoverageException
_the_coverage = None
def _singleton_method(name):
- def func(*args, **kwargs):
+ """Return a function to the `name` method on a singleton `coverage` object.
+
+ The singleton object is created the first time one of these functions is
+ called.
+
+ """
+ def wrapper(*args, **kwargs):
+ """Singleton wrapper around a coverage method."""
global _the_coverage
if not _the_coverage:
_the_coverage = coverage()
return getattr(_the_coverage, name)(*args, **kwargs)
- return func
+ return wrapper
+
# Define the module-level functions.
use_cache = _singleton_method('use_cache')