Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_subprocess._SuppressCoreFiles Class Reference
Inheritance diagram for test.test_subprocess._SuppressCoreFiles:
Inheritance graph
[legend]
Collaboration diagram for test.test_subprocess._SuppressCoreFiles:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __enter__
def __exit__

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 old_limit = None

Detailed Description

Try to prevent core files from being created.

Definition at line 729 of file test_subprocess.py.


Member Function Documentation

Try to save previous ulimit, then set it to (0, 0).

Definition at line 733 of file test_subprocess.py.

00733 
00734     def __enter__(self):
00735         """Try to save previous ulimit, then set it to (0, 0)."""
00736         try:
00737             import resource
00738             self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
00739             resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
00740         except (ImportError, ValueError, resource.error):
00741             pass
00742 
00743         if sys.platform == 'darwin':
00744             # Check if the 'Crash Reporter' on OSX was configured
00745             # in 'Developer' mode and warn that it will get triggered
00746             # when it is.
00747             #
00748             # This assumes that this context manager is used in tests
00749             # that might trigger the next manager.
00750             value = subprocess.Popen(['/usr/bin/defaults', 'read',
00751                     'com.apple.CrashReporter', 'DialogType'],
00752                     stdout=subprocess.PIPE).communicate()[0]
00753             if value.strip() == b'developer':
00754                 print("this tests triggers the Crash Reporter, "
00755                       "that is intentional", end='')
00756                 sys.stdout.flush()

Return core file behavior to default.

Definition at line 757 of file test_subprocess.py.

00757 
00758     def __exit__(self, *args):
00759         """Return core file behavior to default."""
00760         if self.old_limit is None:
00761             return
00762         try:
00763             import resource
00764             resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
00765         except (ImportError, ValueError, resource.error):
00766             pass
00767 
00768 
@unittest.skipIf(mswindows, "POSIX specific tests")

Here is the caller graph for this function:


Member Data Documentation

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 731 of file test_subprocess.py.


The documentation for this class was generated from the following file: