Skip to content

Commit 949d19e

Browse files
committed
Drop --cpp-arguments in favor of using pytest's -o option
Using -o we don't need an additional command-line option just for that. Follow up to #36
1 parent 73a6482 commit 949d19e

3 files changed

Lines changed: 14 additions & 21 deletions

File tree

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,22 @@ ini configuration:
5555
5656
By default matches ``test_*`` and ``*_test`` executable files.
5757

58-
Additional arguments to the C++ tests can be provided with the option
59-
``--cpp-arguments`` or with the ``cpp_arguments`` ini configuration.
58+
Additional arguments to the C++ tests can be provided with the
59+
``cpp_arguments`` ini configuration.
60+
6061
For example:
6162

6263
.. code-block:: ini
6364
6465
[pytest]
6566
cpp_arguments=-v --log-dir=logs
6667
67-
Or the same with the command line option:
68+
You can change this option directly in the command-line using
69+
pytest's ``-o`` option:
6870

6971
.. code-block:: console
7072
71-
$ pytest --cpp-arguments='-v --log-dir=logs'
73+
$ pytest -o cpp_arguments='-v --log-dir=logs'
7274
7375
7476
Requirements
@@ -83,7 +85,7 @@ Install
8385
Install using `pip <http://pip-installer.org/>`_:
8486

8587
.. code-block:: console
86-
88+
8789
$ pip install pytest-cpp
8890
8991
Changelog

pytest_cpp/plugin.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ def pytest_collect_file(parent, path):
2525
config = parent.config
2626
masks = config.getini('cpp_files') or DEFAULT_MASKS
2727

28-
test_args = config.getoption(_ARGUMENTS)
29-
if test_args:
30-
test_args = test_args.split()
31-
else:
32-
test_args = config.getini(_ARGUMENTS) or ()
28+
test_args = config.getini(_ARGUMENTS) or ()
3329

3430
if not parent.session.isinitpath(path):
3531
for pat in masks:
@@ -51,9 +47,6 @@ def pytest_addoption(parser):
5147
default='',
5248
help='Additional arguments for test executables')
5349

54-
group = parser.getgroup('cpp tests')
55-
group.addoption('--cpp-arguments', help='Additional test arguments')
56-
5750

5851
class CppFile(pytest.File):
5952
def __init__(self, path, parent, facade, arguments):

tests/test_pytest_cpp.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_cpp_failure_repr(dummy_failure):
245245
def test_cpp_files_option(testdir, exes):
246246
exes.get('boost_success')
247247
exes.get('gtest')
248-
248+
249249
result = testdir.inline_run('--collect-only')
250250
reps = result.getreports()
251251
assert len(reps) == 1
@@ -290,7 +290,7 @@ def test_google_one_argument_via_option(testdir, exes):
290290
result = testdir.inline_run(exes.get('gtest_args'),
291291
'-k',
292292
'ArgsTest.one_argument',
293-
'--cpp-arguments', 'argument1')
293+
'-o', 'cpp_arguments=argument1')
294294
assert_outcomes(result,
295295
[('ArgsTest.one_argument', 'passed')])
296296

@@ -299,8 +299,7 @@ def test_google_two_arguments_via_option(testdir, exes):
299299
result = testdir.inline_run(exes.get('gtest_args'),
300300
'-k',
301301
'ArgsTest.two_arguments',
302-
'--cpp-arguments',
303-
'argument1 argument2')
302+
'-o', 'cpp_arguments=argument1 argument2')
304303
assert_outcomes(result,
305304
[('ArgsTest.two_arguments', 'passed')])
306305

@@ -313,7 +312,7 @@ def test_argument_option_priority(testdir, exes):
313312
result = testdir.inline_run(exes.get('gtest_args'),
314313
'-k',
315314
'ArgsTest.one_argument',
316-
'--cpp-arguments', 'argument1')
315+
'-o', 'cpp_arguments=argument1')
317316
assert_outcomes(result,
318317
[('ArgsTest.one_argument', 'passed')])
319318

@@ -342,15 +341,14 @@ def test_boost_two_arguments(testdir, exes):
342341

343342
def test_boost_one_argument_via_option(testdir, exes):
344343
result = testdir.inline_run(exes.get('boost_one_argument'),
345-
'--cpp-arguments',
346-
'argument1')
344+
'-o', 'cpp_arguments=argument1')
347345
assert_outcomes(result,
348346
[('boost_one_argument', 'passed')])
349347

350348

351349
def test_boost_two_arguments_via_option(testdir, exes):
352350
result = testdir.inline_run(exes.get('boost_two_arguments'),
353-
'--cpp-arguments=argument1 argument2')
351+
'-o', 'cpp_arguments=argument1 argument2')
354352
assert_outcomes(result,
355353
[('boost_two_arguments', 'passed')])
356354

0 commit comments

Comments
 (0)