summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-09-24 21:03:16 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-09-24 21:03:16 -0400
commit7b5457967f256696d3b6c936e81436aa60b4b409 (patch)
tree6cc4e2517a408a730a525c4ee98ad38f3a532cff /coverage
parent2eb5fe3be624d8f970d0394d32a1f2fa148a9372 (diff)
downloadpython-coveragepy-git-7b5457967f256696d3b6c936e81436aa60b4b409.tar.gz
"concurrency" is a better name that "coroutine"
--HG-- rename : tests/test_coroutine.py => tests/test_concurrency.py
Diffstat (limited to 'coverage')
-rw-r--r--coverage/cmdline.py12
-rw-r--r--coverage/collector.py44
-rw-r--r--coverage/config.py4
-rw-r--r--coverage/control.py8
-rw-r--r--coverage/tracer.c20
5 files changed, 44 insertions, 44 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index c723fa95..51aa5fe5 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -19,9 +19,9 @@ class Opts(object):
'', '--branch', action='store_true',
help="Measure branch coverage in addition to statement coverage."
)
- coroutine = optparse.make_option(
- '', '--coroutine', action='store', metavar="LIB",
- help="Properly measure code using coroutines."
+ concurrency = optparse.make_option(
+ '', '--concurrency', action='store', metavar="LIB",
+ help="Properly measure code using a concurrency library."
)
debug = optparse.make_option(
'', '--debug', action='store', metavar="OPTS",
@@ -125,7 +125,7 @@ class CoverageOptionParser(optparse.OptionParser, object):
self.set_defaults(
actions=[],
branch=None,
- coroutine=None,
+ concurrency=None,
debug=None,
directory=None,
fail_under=None,
@@ -320,7 +320,7 @@ CMDS = {
[
Opts.append,
Opts.branch,
- Opts.coroutine,
+ Opts.concurrency,
Opts.debug,
Opts.pylib,
Opts.parallel_mode,
@@ -429,7 +429,7 @@ class CoverageScript(object):
omit = omit,
include = include,
debug = debug,
- coroutine = options.coroutine,
+ concurrency = options.concurrency,
)
if 'debug' in options.actions:
diff --git a/coverage/collector.py b/coverage/collector.py
index 97b45deb..07318240 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -46,7 +46,7 @@ class Collector(object):
_collectors = []
def __init__(self,
- should_trace, check_include, timid, branch, warn, coroutine,
+ should_trace, check_include, timid, branch, warn, concurrency,
):
"""Create a collector.
@@ -68,7 +68,7 @@ class Collector(object):
`warn` is a warning function, taking a single string message argument,
to be used if a warning needs to be issued.
- TODO: `coroutine`
+ TODO: `concurrency`
"""
self.should_trace = should_trace
@@ -76,21 +76,21 @@ class Collector(object):
self.warn = warn
self.branch = branch
self.threading = None
- self.coroutine = coroutine
+ self.concurrency = concurrency
- self.coroutine_id_func = None
+ self.concur_id_func = None
try:
- if coroutine == "greenlet":
- import greenlet
- self.coroutine_id_func = greenlet.getcurrent
- elif coroutine == "eventlet":
- import eventlet.greenthread
- self.coroutine_id_func = eventlet.greenthread.getcurrent
- elif coroutine == "gevent":
- import gevent
- self.coroutine_id_func = gevent.getcurrent
- elif coroutine == "thread" or not coroutine:
+ if concurrency == "greenlet":
+ import greenlet # pylint: disable=import-error
+ self.concur_id_func = greenlet.getcurrent
+ elif concurrency == "eventlet":
+ import eventlet.greenthread # pylint: disable=import-error
+ self.concur_id_func = eventlet.greenthread.getcurrent
+ elif concurrency == "gevent":
+ import gevent # pylint: disable=import-error
+ self.concur_id_func = gevent.getcurrent
+ elif concurrency == "thread" or not concurrency:
# It's important to import threading only if we need it. If
# it's imported early, and the program being measured uses
# gevent, then gevent's monkey-patching won't work properly.
@@ -98,12 +98,12 @@ class Collector(object):
self.threading = threading
else:
raise CoverageException(
- "Don't understand coroutine=%s" % coroutine
+ "Don't understand concurrency=%s" % concurrency
)
except ImportError:
raise CoverageException(
- "Couldn't trace with coroutine=%s, "
- "the module isn't installed." % coroutine
+ "Couldn't trace with concurrency=%s, "
+ "the module isn't installed." % concurrency
)
self.reset()
@@ -148,13 +148,13 @@ class Collector(object):
tracer.should_trace_cache = self.should_trace_cache
tracer.warn = self.warn
- if hasattr(tracer, 'coroutine_id_func'):
- tracer.coroutine_id_func = self.coroutine_id_func
- elif self.coroutine_id_func:
+ if hasattr(tracer, 'concur_id_func'):
+ tracer.concur_id_func = self.concur_id_func
+ elif self.concur_id_func:
raise CoverageException(
- "Can't support coroutine=%s with %s, "
+ "Can't support concurrency=%s with %s, "
"only threads are supported" % (
- self.coroutine, self.tracer_name(),
+ self.concurrency, self.tracer_name(),
)
)
diff --git a/coverage/config.py b/coverage/config.py
index c671ef75..44bf3930 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -140,7 +140,7 @@ class CoverageConfig(object):
# Defaults for [run]
self.branch = False
- self.coroutine = None
+ self.concurrency = None
self.cover_pylib = False
self.data_file = ".coverage"
self.parallel = False
@@ -235,7 +235,7 @@ class CoverageConfig(object):
# [run]
('branch', 'run:branch', 'boolean'),
- ('coroutine', 'run:coroutine'),
+ ('concurrency', 'run:concurrency'),
('cover_pylib', 'run:cover_pylib', 'boolean'),
('data_file', 'run:data_file'),
('debug', 'run:debug', 'list'),
diff --git a/coverage/control.py b/coverage/control.py
index 86a2ae23..510ced7b 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -45,7 +45,7 @@ class Coverage(object):
def __init__(self, data_file=None, data_suffix=None, cover_pylib=None,
auto_data=False, timid=None, branch=None, config_file=True,
source=None, omit=None, include=None, debug=None,
- debug_file=None, coroutine=None, plugins=None):
+ debug_file=None, concurrency=None, plugins=None):
"""
`data_file` is the base name of the data file to use, defaulting to
".coverage". `data_suffix` is appended (with a dot) to `data_file` to
@@ -84,7 +84,7 @@ class Coverage(object):
desired. `debug_file` is the file to write debug messages to,
defaulting to stderr.
- `coroutine` is a string indicating the coroutining library being used
+ `concurrency` is a string indicating the concurrency library being used
in the measured code. Without this, coverage.py will get incorrect
results. Valid strings are "greenlet", "eventlet", or "gevent", which
are all equivalent. TODO: really?
@@ -128,7 +128,7 @@ class Coverage(object):
data_file=data_file, cover_pylib=cover_pylib, timid=timid,
branch=branch, parallel=bool_or_none(data_suffix),
source=source, omit=omit, include=include, debug=debug,
- coroutine=coroutine, plugins=plugins,
+ concurrency=concurrency, plugins=plugins,
)
# Create and configure the debugging controller.
@@ -170,7 +170,7 @@ class Coverage(object):
timid=self.config.timid,
branch=self.config.branch,
warn=self._warn,
- coroutine=self.config.coroutine,
+ concurrency=self.config.concurrency,
)
# Suffixes are a bit tricky. We want to use the data suffix only when
diff --git a/coverage/tracer.c b/coverage/tracer.c
index 5bf5c462..dcc3b727 100644
--- a/coverage/tracer.c
+++ b/coverage/tracer.c
@@ -81,7 +81,7 @@ typedef struct {
/* Python objects manipulated directly by the Collector class. */
PyObject * should_trace;
PyObject * warn;
- PyObject * coroutine_id_func;
+ PyObject * concur_id_func;
PyObject * data;
PyObject * plugin_data;
PyObject * should_trace_cache;
@@ -104,8 +104,8 @@ typedef struct {
(None).
*/
- DataStack data_stack; /* Used if we aren't doing coroutines. */
- PyObject * data_stack_index; /* Used if we are doing coroutines. */
+ DataStack data_stack; /* Used if we aren't doing concurrency. */
+ PyObject * data_stack_index; /* Used if we are doing concurrency. */
DataStack * data_stacks;
int data_stacks_alloc;
int data_stacks_used;
@@ -191,7 +191,7 @@ CTracer_init(CTracer *self, PyObject *args_unused, PyObject *kwds_unused)
self->should_trace = NULL;
self->warn = NULL;
- self->coroutine_id_func = NULL;
+ self->concur_id_func = NULL;
self->data = NULL;
self->plugin_data = NULL;
self->should_trace_cache = NULL;
@@ -234,7 +234,7 @@ CTracer_dealloc(CTracer *self)
Py_XDECREF(self->should_trace);
Py_XDECREF(self->warn);
- Py_XDECREF(self->coroutine_id_func);
+ Py_XDECREF(self->concur_id_func);
Py_XDECREF(self->data);
Py_XDECREF(self->plugin_data);
Py_XDECREF(self->should_trace_cache);
@@ -327,18 +327,18 @@ CTracer_record_pair(CTracer *self, int l1, int l2)
static int
CTracer_set_pdata_stack(CTracer *self)
{
- if (self->coroutine_id_func != Py_None) {
+ if (self->concur_id_func != Py_None) {
PyObject * co_obj = NULL;
PyObject * stack_index = NULL;
long the_index = 0;
- co_obj = PyObject_CallObject(self->coroutine_id_func, NULL);
+ co_obj = PyObject_CallObject(self->concur_id_func, NULL);
if (co_obj == NULL) {
return RET_ERROR;
}
stack_index = PyDict_GetItem(self->data_stack_index, co_obj);
if (stack_index == NULL) {
- /* A new coroutine object. Make a new data stack. */
+ /* A new concurrency object. Make a new data stack. */
the_index = self->data_stacks_used;
stack_index = MyInt_FromLong(the_index);
if (PyDict_SetItem(self->data_stack_index, co_obj, stack_index) < 0) {
@@ -781,8 +781,8 @@ CTracer_members[] = {
{ "warn", T_OBJECT, offsetof(CTracer, warn), 0,
PyDoc_STR("Function for issuing warnings.") },
- { "coroutine_id_func", T_OBJECT, offsetof(CTracer, coroutine_id_func), 0,
- PyDoc_STR("Function for determining coroutine context") },
+ { "concur_id_func", T_OBJECT, offsetof(CTracer, concur_id_func), 0,
+ PyDoc_STR("Function for determining concurrency context") },
{ "data", T_OBJECT, offsetof(CTracer, data), 0,
PyDoc_STR("The raw dictionary of trace data.") },