URL: https://github.com/freeipa/freeipa/pull/374
Author: tiran
 Title: #374: pytest: set rules to find test files and functions
Action: opened

PR body:
"""
1e06a5195bafe0224d77371987f2509f5508ca2f removed pytest.ini. Without the
ini file, pytest 3.x has suboptimal settings and no longer picks up all
test functions and test files.

Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/374/head:pr374
git checkout pr374
From d59564aa23f7328c2606d6645de22a6bed0192d6 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Thu, 5 Jan 2017 19:29:22 +0100
Subject: [PATCH] pytest: set rules to find test files and functions

1e06a5195bafe0224d77371987f2509f5508ca2f removed pytest.ini. Without the
ini file, pytest 3.x has suboptimal settings and no longer picks up all
test functions and test files.

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 ipatests/conftest.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ipatests/conftest.py b/ipatests/conftest.py
index 45920de..6d8ba60 100644
--- a/ipatests/conftest.py
+++ b/ipatests/conftest.py
@@ -42,6 +42,12 @@
     'install/share'
 ]
 
+INIVALUES = {
+    'python_classes': ['test_', 'Test'],
+    'python_files': ['test_*.py'],
+    'python_functions': ['test_*'],
+}
+
 
 def pytest_configure(config):
     # add pytest markers
@@ -52,12 +58,10 @@ def pytest_configure(config):
     for norecursedir in NO_RECURSE_DIRS:
         config.addinivalue_line('norecursedirs', norecursedir)
 
-    # load test classes with these prefixes.
-    # addinivalue_line() adds duplicated entries.
-    python_classes = config.getini('python_classes')
-    for value in ['test_', 'Test']:
-        if value not in python_classes:
-            python_classes.append(value)
+    # addinivalue_line() adds duplicated entries and does not remove existing.
+    for name, values in INIVALUES.items():
+        current = config.getini(name)
+        current[:] = values
 
     # set default JUnit prefix
     if config.option.junitprefix is None:
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to