[issue12231] regrtest: add -k and -K options to filter tests by function/file names

STINNER Victor report at bugs.python.org
Wed Jun 1 01:56:14 CEST 2011


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

Attached patch adds -k/--func-regex and -K/--file-regex options to filter tests by function/file names. It modifies makeSuite() and getTestCaseNames() functions of unittest.loader to add an optional filter argument: callback taking a function name as argument and returning False if the test should be ignored. You can use the new options more than once and their argument are regular expressions (case insensitive).

Examples:

- "./python -m test -k subprocess -K pass_fds" runs only 1 function of 1 file: test_subprocess.test_pass_fds()
- "./python -m test -k os$" runs 1 file: test_os
- "./python -m test -K codecencoding" runs 6 files: test_codecencodings_cn, test_codecencodings_hk, test_codecencodings_iso2022, test_codecencodings_jp, test_codecencodings_kr, test_codecencodings_tw

----------
components: Tests
files: regrtest_regex.patch
keywords: patch
messages: 137402
nosy: haypo
priority: normal
severity: normal
status: open
title: regrtest: add -k and -K options to filter tests by function/file names
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file22216/regrtest_regex.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12231>
_______________________________________


More information about the Python-bugs-list mailing list