diff --git a/Tests/ldif/subschema-ipa.demo1.freeipa.org.ldif b/Tests/data/subschema-ipa.demo1.freeipa.org.ldif similarity index 100% rename from Tests/ldif/subschema-ipa.demo1.freeipa.org.ldif rename to Tests/data/subschema-ipa.demo1.freeipa.org.ldif diff --git a/Tests/ldif/subschema-openldap-all.ldif b/Tests/data/subschema-openldap-all.ldif similarity index 100% rename from Tests/ldif/subschema-openldap-all.ldif rename to Tests/data/subschema-openldap-all.ldif diff --git a/Tests/t_ldap_schema_subentry.py b/Tests/t_ldap_schema_subentry.py index 83ed006..ee79072 100644 --- a/Tests/t_ldap_schema_subentry.py +++ b/Tests/t_ldap_schema_subentry.py @@ -5,6 +5,7 @@ See https://www.python-ldap.org/ for details. """ +import os import unittest import time @@ -12,9 +13,11 @@ import ldap.schema from ldap.schema.models import ObjectClass +HERE = os.path.abspath(os.path.dirname(__file__)) + TEST_SUBSCHEMA_FILES = ( - 'Tests/ldif/subschema-ipa.demo1.freeipa.org.ldif', - 'Tests/ldif/subschema-openldap-all.ldif', + os.path.join(HERE, 'data', 'subschema-ipa.demo1.freeipa.org.ldif'), + os.path.join(HERE, 'data', 'subschema-openldap-all.ldif'), ) class TestSubschemaLDIF(unittest.TestCase): @@ -25,9 +28,9 @@ class TestSubschemaLDIF(unittest.TestCase): def test_subschema_file(self): for test_file in TEST_SUBSCHEMA_FILES: # Read and parse LDIF file - ldif_file = open(test_file, 'rb') - ldif_parser = ldif.LDIFRecordList(ldif_file,max_entries=1) - ldif_parser.parse() + with open(test_file, 'rb') as ldif_file: + ldif_parser = ldif.LDIFRecordList(ldif_file,max_entries=1) + ldif_parser.parse() _, subschema_subentry = ldif_parser.all_records[0] sub_schema = ldap.schema.SubSchema(subschema_subentry) diff --git a/tox.ini b/tox.ini index b2d435c..22ca4a8 100644 --- a/tox.ini +++ b/tox.ini @@ -9,8 +9,20 @@ envlist = py27,py33,py34,py35,py36,coverage-report [testenv] deps = coverage -commands = {envpython} -m coverage run --parallel setup.py test passenv = WITH_GCOV +# - Enable BytesWarning +# - Turn all warnings into exceptions. +# - 'ignore:the imp module is deprecated' is required to ignore import of +# 'imp' in distutils. Python 3.3 and 3.4 use PendingDeprecationWarning. +commands = {envpython} -bb -Werror \ + "-Wignore:the imp module is deprecated:DeprecationWarning" \ + "-Wignore:the imp module is deprecated:PendingDeprecationWarning" \ + -m coverage run --parallel setup.py test + +[testenv:py27] +# No warnings with Python 2.7 +commands = {envpython} \ + -m coverage run --parallel setup.py test [testenv:coverage-report] deps = coverage