summaryrefslogtreecommitdiff
path: root/psutil/_psutil_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'psutil/_psutil_common.c')
-rw-r--r--psutil/_psutil_common.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c
index bcbd623b..37cc2f16 100644
--- a/psutil/_psutil_common.c
+++ b/psutil/_psutil_common.c
@@ -7,6 +7,7 @@
*/
#include <Python.h>
+#include <stdio.h>
/*
* Set OSError(errno=ESRCH, strerror="No such process") Python exception.
@@ -37,6 +38,30 @@ AccessDenied(void) {
/*
+ * Return 1 if PSUTIL_TESTING env var is set else 0.
+ */
+int
+psutil_testing(void) {
+ if (getenv("PSUTIL_TESTING") != NULL)
+ return 1;
+ else
+ return 0;
+}
+
+
+/*
+ * Return True if PSUTIL_TESTING env var is set else False.
+ */
+PyObject *
+py_psutil_testing(PyObject *self, PyObject *args) {
+ PyObject *res;
+ res = psutil_testing() ? Py_True : Py_False;
+ Py_INCREF(res);
+ return res;
+}
+
+
+/*
* Backport of unicode FS APIs from Python 3.
* On Python 2 we just return a plain byte string
* which is never supposed to raise decoding errors.
@@ -52,4 +77,4 @@ PyObject *
PyUnicode_DecodeFSDefaultAndSize(char *s, Py_ssize_t size) {
return PyString_FromStringAndSize(s, size);
}
-#endif \ No newline at end of file
+#endif