Enable additional warnings (BytesWarning, DeprecationWarning)

Closes: https://fedorahosted.org/freeipa/ticket/6631
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Christian Heimes 2017-02-10 14:19:07 +01:00 committed by Martin Basti
parent dd119f8aad
commit a33b25dea9
2 changed files with 40 additions and 7 deletions

View File

@ -880,8 +880,46 @@ freeIPA.org:
http://freeipa.org/page/Contribute
'''
version_info = (2, 0, 0, 'alpha', 0)
if version_info[3] == 'final':
__version__ = '%d.%d.%d' % version_info[:3]
else:
__version__ = '%d.%d.%d.%s.%d' % version_info
import os
def _enable_warnings(error=False):
"""Enable additional warnings during development
"""
import ctypes
import warnings
# get reference to Py_BytesWarningFlag from Python CAPI
byteswarnings = ctypes.c_int.in_dll( # pylint: disable=no-member
ctypes.pythonapi, 'Py_BytesWarningFlag')
if byteswarnings.value >= 2:
# bytes warnings flag already set to error
return
# default warning mode for all modules: warn once per location
warnings.simplefilter('default', BytesWarning)
if error:
byteswarnings.value = 2
action = 'error'
else:
byteswarnings.value = 1
action = 'default'
module = '(ipa.*|__main__)'
warnings.filterwarnings(action, category=BytesWarning, module=module)
warnings.filterwarnings(action, category=DeprecationWarning,
module=module)
# call this as early as possible
if version_info[3] != 'final':
_enable_warnings(False)
# noqa: E402
from ipalib import plugable
from ipalib.backend import Backend
from ipalib.frontend import Command, LocalOrRemote, Updater
@ -893,12 +931,6 @@ from ipalib.parameters import (BytesEnum, StrEnum, IntEnum, AccessTime, File,
from ipalib.errors import SkipPluginModule
from ipalib.text import _, ngettext, GettextFactory, NGettextFactory
version_info = (2, 0, 0, 'alpha', 0)
if version_info[3] == 'final':
__version__ = '%d.%d.%d' % version_info[:3]
else:
__version__ = '%d.%d.%d.%s.%d' % version_info
Registry = plugable.Registry

View File

@ -32,6 +32,7 @@ import sys
import pytest
import ipalib
import ipatests
# This is set to store --with-xunit report in an accessible place: