File: version_dep.py

package info (click to toggle)
pydicom 0.9.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,884 kB
  • ctags: 645
  • sloc: python: 20,945; sh: 17; makefile: 5
file content (19 lines) | stat: -rw-r--r-- 756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# version_dep.py
"""Holds test code that is dependent of certain python versions"""
# Copyright (c) 2009 Darcy Mason
# This file is part of pydicom, released under a modified MIT license.
#    See the file license.txt included with this distribution, also
#    available at http://pydicom.googlecode.com

from __future__ import with_statement
import warnings

def capture_warnings(function, *func_args, **func_kwargs):
    """Capture and function result and warnings.
    For python > 2.5
    """
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        result = function(*func_args, **func_kwargs)
        all_warnings = w
    return result, [str(warning.message) for warning in all_warnings]