Skip to content

Commit

Permalink
Run tests with warnings and bytes warnings
Browse files Browse the repository at this point in the history
All warnings except expected warnings are turned into exceptions.

Fixed a resource warning in schema test case.

Rename Tests/ldif to Tests/data to prevent an ImportWarning with Python 2:

    Traceback (most recent call last):
    ...
    ImportWarning: Not importing directory 'Tests/ldif': missing __init__.py

https://github.com/python-ldap/python-ldap/pull/15
Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and Petr Viktorin committed Nov 28, 2017
1 parent 9f6f142 commit 4b97671
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
File renamed without changes.
13 changes: 8 additions & 5 deletions Tests/t_ldap_schema_subentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
See https://www.python-ldap.org/ for details.
"""

import os
import unittest
import time

import ldif
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):
Expand All @@ -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)

Expand Down
14 changes: 13 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b97671

Please sign in to comment.