本文整理汇总了Python中gc.DEBUG_LEAK属性的典型用法代码示例。如果您正苦于以下问题:Python gc.DEBUG_LEAK属性的具体用法?Python gc.DEBUG_LEAK怎么用?Python gc.DEBUG_LEAK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gc
的用法示例。
在下文中一共展示了gc.DEBUG_LEAK属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: argp_add_default_args
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def argp_add_default_args(parser, default_root=''):
"""
Add standard arguments to a new :py:class:`argparse.ArgumentParser`
instance. Used to add the utilities argparse options to the wrapper for
display.
:param parser: The parser to add arguments to.
:type parser: :py:class:`argparse.ArgumentParser`
:param str default_root: The default root logger to specify.
"""
parser.add_argument('-v', '--version', action='version', version=parser.prog + ' Version: ' + version.version)
log_group = parser.add_argument_group('logging options')
log_group.add_argument('-L', '--log', dest='loglvl', type=str.upper, choices=('DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL'), help='set the logging level')
log_group.add_argument('--logger', default=default_root, help='specify the root logger')
gc_group = parser.add_argument_group('garbage collector options')
gc_group.add_argument('--gc-debug-leak', action='store_const', const=gc.DEBUG_LEAK, default=0, help='set the DEBUG_LEAK flag')
gc_group.add_argument('--gc-debug-stats', action='store_const', const=gc.DEBUG_STATS, default=0, help='set the DEBUG_STATS flag')
return parser
示例2: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_main():
enabled = gc.isenabled()
gc.disable()
assert not gc.isenabled()
debug = gc.get_debug()
gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak
try:
gc.collect() # Delete 2nd generation garbage
run_unittest(GCTests, GCTogglingTests)
finally:
gc.set_debug(debug)
# test gc.enable() even if GC is disabled by default
if verbose:
print "restoring automatic collection"
# make sure to always test gc.enable()
gc.enable()
assert gc.isenabled()
if not enabled:
gc.disable()
示例3: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_main():
enabled = gc.isenabled()
gc.disable()
assert not gc.isenabled()
debug = gc.get_debug()
gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak
try:
gc.collect() # Delete 2nd generation garbage
run_unittest(GCTests, GCTogglingTests, GCCallbackTests)
finally:
gc.set_debug(debug)
# test gc.enable() even if GC is disabled by default
if verbose:
print("restoring automatic collection")
# make sure to always test gc.enable()
gc.enable()
assert gc.isenabled()
if not enabled:
gc.disable()
示例4: test
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test():
if verbose:
print "disabling automatic collection"
enabled = gc.isenabled()
gc.disable()
verify(not gc.isenabled())
debug = gc.get_debug()
gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak
try:
test_all()
finally:
gc.set_debug(debug)
# test gc.enable() even if GC is disabled by default
if verbose:
print "restoring automatic collection"
# make sure to always test gc.enable()
gc.enable()
verify(gc.isenabled())
if not enabled:
gc.disable()
示例5: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_main():
enabled = gc.isenabled()
try:
gc.disable()
assert not gc.isenabled()
except NotImplementedError:
pass
debug = gc.get_debug()
gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak
try:
gc.collect() # Delete 2nd generation garbage
run_unittest(GCTests, GCTogglingTests)
finally:
gc.set_debug(debug)
# test gc.enable() even if GC is disabled by default
if verbose:
print "restoring automatic collection"
# make sure to always test gc.enable()
gc.enable()
assert gc.isenabled()
if not enabled:
gc.disable()
示例6: test_debug_stats
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_debug_stats(self):
self.assertEqual(1,gc.DEBUG_STATS)
self.assertEqual(2,gc.DEBUG_COLLECTABLE)
self.assertEqual(4,gc.DEBUG_UNCOLLECTABLE)
self.assertEqual(8,gc.DEBUG_INSTANCES)
self.assertEqual(16,gc.DEBUG_OBJECTS)
self.assertEqual(32,gc.DEBUG_SAVEALL)
self.assertEqual(62,gc.DEBUG_LEAK)
示例7: test_get_debug
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_get_debug(self):
state = [0,gc.DEBUG_STATS,gc.DEBUG_COLLECTABLE,gc.DEBUG_UNCOLLECTABLE,gc.DEBUG_INSTANCES,gc.DEBUG_OBJECTS,gc.DEBUG_SAVEALL,gc.DEBUG_LEAK]
result = gc.get_debug()
if result not in state:
self.fail("Returned value of getdebug method is not valid value:" + str(result))
示例8: test_debug_stats
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_debug_stats(self):
self.assertEqual(1,gc.DEBUG_STATS)
self.assertEqual(2,gc.DEBUG_COLLECTABLE)
self.assertEqual(4,gc.DEBUG_UNCOLLECTABLE)
self.assertEqual(32,gc.DEBUG_SAVEALL)
self.assertEqual(38,gc.DEBUG_LEAK)
示例9: test_get_debug
# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_LEAK [as 别名]
def test_get_debug(self):
state = [0,gc.DEBUG_STATS,gc.DEBUG_COLLECTABLE,gc.DEBUG_UNCOLLECTABLE,gc.DEBUG_SAVEALL,gc.DEBUG_LEAK]
result = gc.get_debug()
if result not in state:
self.fail("Returned value of getdebug method is not valid value:" + str(result))