From 2ad72f26e809aeb6e014663f545384f8ee50ae61 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 11 Dec 2017 14:20:57 +0100 Subject: [PATCH] Minimal configuration for pytest Configure setup.cfg for pytest python-ldap uses a non-standard configuration for tests. Also, fix test class: TestSubschemaUrlfetch must be a subclass of TestCase, not TestSuite. https://github.com/python-ldap/python-ldap/pull/114 Signed-off-by: Christian Heimes --- .gitignore | 1 + Doc/contributing.rst | 2 +- Tests/t_ldap_schema_subentry.py | 3 ++- setup.cfg | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4e261ca..962248f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ .tox .coverage* !.coveragerc +/.cache # shared libs installed by 'setup.py test' /Lib/*.so* diff --git a/Doc/contributing.rst b/Doc/contributing.rst index 45c40f3..abefc4a 100644 --- a/Doc/contributing.rst +++ b/Doc/contributing.rst @@ -224,7 +224,7 @@ Run reference leak tests:: $ cd path/to/python-ldap $ /tmp/refleak/bin/pip install --upgrade . - $ /tmp/refleak/bin/pytest -v -R: Tests/t_*.py + $ /tmp/refleak/bin/pytest -v -R: Run ``/tmp/refleak/bin/pip install --upgrade .`` every time a file outside of ``Tests/`` is modified. diff --git a/Tests/t_ldap_schema_subentry.py b/Tests/t_ldap_schema_subentry.py index d406b46..3c07d35 100644 --- a/Tests/t_ldap_schema_subentry.py +++ b/Tests/t_ldap_schema_subentry.py @@ -25,6 +25,7 @@ os.path.join(HERE, 'data', 'subschema-openldap-all.ldif'), ) + class TestSubschemaLDIF(unittest.TestCase): """ test ldap.schema.SubSchema with subschema subentries read from LDIF files @@ -49,7 +50,7 @@ def test_subschema_file(self): self.assertEqual(attributetype.oid, oid) -class TestSubschemaUrlfetch(unittest.TestSuite): +class TestSubschemaUrlfetch(unittest.TestCase): def test_urlfetch_file(self): freeipa_uri = 'file://{}'.format(TEST_SUBSCHEMA_FILES[0]) dn, schema = ldap.schema.urlfetch(freeipa_uri) diff --git a/setup.cfg b/setup.cfg index 34699da..374dd42 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,3 +35,11 @@ packager = python-ldap team distribution_name = openSUSE 11.x release = 1 doc_files = CHANGES README INSTALL TODO Demo/ + +# pytest, https://docs.pytest.org/en/latest/customize.html +[tool:pytest] +testpaths = Tests +python_files = t_*.py +filterwarnings = + error + ignore::ldap.LDAPBytesWarning