Skip to content

Commit 08d0326

Browse files
committed
Update README and CHANGELOG with cpp_ignore_py_files
1 parent 15e0acf commit 08d0326

3 files changed

Lines changed: 34 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# 1.2.0
22

33
- `pytest-cpp` no longer supports Python 3.4.
4+
- New `cpp_ignore_py_files` option that makes the plugin ignore `*.py` files even if they
5+
would otherwise match the `cpp_files` option (defaults to `True`).
46

57
# 1.1.0
68

README.rst

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,34 @@ Once installed, when py.test runs it will search and run tests
4545
found in executable files, detecting if the suites are
4646
Google or Boost tests automatically.
4747

48+
Configuration Options
49+
~~~~~~~~~~~~~~~~~~~~~
50+
51+
**cpp_files**
52+
4853
You can configure which files are tested for suites by using the ``cpp_files``
49-
ini configuration:
54+
ini configuration option:
5055

5156
.. code-block:: ini
5257
5358
[pytest]
54-
cpp_files=test_suite*
59+
cpp_files = test_suite*
5560
5661
By default matches ``test_*`` and ``*_test`` executable files.
5762

58-
Additional arguments to the C++ tests can be provided with the
59-
``cpp_arguments`` ini configuration.
63+
**cpp_arguments**
6064

6165
*New in version 1.1*.
6266

67+
Arguments to the C++ tests can be provided with the
68+
``cpp_arguments`` ini configuration option.
69+
6370
For example:
6471

6572
.. code-block:: ini
6673
6774
[pytest]
68-
cpp_arguments=-v --log-dir=logs
75+
cpp_arguments =-v --log-dir=logs
6976
7077
You can change this option directly in the command-line using
7178
pytest's ``-o`` option:
@@ -74,12 +81,19 @@ pytest's ``-o`` option:
7481
7582
$ pytest -o cpp_arguments='-v --log-dir=logs'
7683
84+
**cpp_ignore_py_files**
85+
86+
*New in version 1.2*.
7787

78-
Requirements
79-
============
88+
This option defaults to ``True`` and configures the plugin to ignore ``*.py`` files that
89+
would otherwise match the ``cpp_files`` option.
8090

81-
* Python 2.7+, Python 3.4+
82-
* pytest
91+
Set it to ``False`` if you have C++ executable files that end with the ``*.py`` extension.
92+
93+
.. code-block:: ini
94+
95+
[pytest]
96+
cpp_ignore_py_files = False
8397
8498
Install
8599
=======

tests/test_pytest_cpp.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,18 @@ def test_cpp_ignore_py_files(testdir, exes):
271271
cpp_files = cpptest_*
272272
''')
273273

274-
result = testdir.inline_run('--collect-only')
275-
reps = result.getreports()
276-
print(reps)
277-
assert len(reps) == 1
278-
assert reps[0].result == []
274+
result = testdir.runpytest('--collect-only')
275+
result.stdout.fnmatch_lines('* no tests ran *')
279276

280-
result = testdir.inline_run('--collect-only', '-o', 'cpp_ignore_py_files=False')
281-
assert len(result.matchreport(exes.exe_name(file_name), when='collect').result) == 4
277+
result = testdir.runpytest('--collect-only', '-o', 'cpp_ignore_py_files=False')
278+
result.stdout.fnmatch_lines("*CppFile cpptest_success.py*")
282279

283280
# running directly skips out machinery as well.
284-
result = testdir.inline_run('--collect-only', file_name)
285-
assert len(result.matchreport(exes.exe_name(file_name), when='collect').result) == 0
286-
287-
result = testdir.inline_run('--collect-only', '-o', 'cpp_ignore_py_files=False', file_name)
288-
# assert len(result.matchreport(exes.exe_name(file_name)).result) == 4
289-
# workaround for a pytest bug
290-
print([(rep.nodeid.split("::"), len(rep.result)) for rep in result.getreports()])
291-
assert any(file_name in rep.nodeid.split("::") and len(rep.result) == 4 for rep in result.getreports())
281+
result = testdir.runpytest('--collect-only', file_name)
282+
result.stdout.fnmatch_lines('*1 error in*')
283+
284+
result = testdir.runpytest('--collect-only', '-o', 'cpp_ignore_py_files=False', file_name)
285+
result.stdout.fnmatch_lines("*CppFile cpptest_success.py*")
292286

293287

294288
def test_google_one_argument(testdir, exes):

0 commit comments

Comments
 (0)