-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call
gc.collect
after each test only if the user asks for it
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import (absolute_import, division, print_function, | ||
unicode_literals) | ||
|
||
import gc | ||
import os | ||
from nose.plugins import Plugin | ||
|
||
|
||
class PerformGC(Plugin): | ||
"""This plugin adds option to call ``gc.collect`` after each test""" | ||
enabled = False | ||
|
||
def options(self, parser, env=os.environ): | ||
env_opt = 'PERFORM_GC' | ||
parser.add_option('--perform-gc', action='store_true', | ||
dest='performGC', default=env.get(env_opt, False), | ||
help='Call gc.collect() after each test') | ||
|
||
def configure(self, options, conf): | ||
if not self.can_configure: | ||
return | ||
|
||
self.enabled = getattr(options, 'performGC', False) | ||
|
||
def afterTest(self, test): | ||
gc.collect() |