Skip to content

Commit

Permalink
Improve test module discovery
Browse files Browse the repository at this point in the history
Accept both `test_*.py` and `*_test.py` as valid test modules patterns.

Fix #135
  • Loading branch information
droideck authored and elyezer committed Mar 30, 2017
1 parent 1289210 commit 689f182
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,8 @@ Appendix
Python Test Modules
+++++++++++++++++++

All files which match the following criteria:

- file names start with ``test_``
- file extension matches ``.py``
All files which match the patterns ``test_*.py`` and ``*_test.py`` are
considered Python test modules.

Python Test case functions
++++++++++++++++++++++++++
Expand Down
6 changes: 5 additions & 1 deletion testimony/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import ast
import collections
import fnmatch
import itertools
import json
import os
Expand Down Expand Up @@ -57,7 +58,10 @@ def prefixed_lines():

def is_test_module(filename):
"""Indicate if ``filename`` match a test module file name."""
return filename.startswith('test_') and filename.endswith('.py')
for pat in ('test_*.py', '*_test.py'):
if fnmatch.fnmatch(filename, pat):
return True
return False


class TestFunction(object):
Expand Down

0 comments on commit 689f182

Please sign in to comment.