| Allen Li | 8c4d01b | 2017-09-22 13:53:16 -0700 | [diff] [blame] | 1 | # Copyright 2017 The Chromium Authors. All rights reserved. | 
|  | 2 | # Use of this source code is governed by a BSD-style license that can be | 
|  | 3 | # found in the LICENSE file. | 
|  | 4 |  | 
|  | 5 | """pytest extensions.""" | 
|  | 6 |  | 
|  | 7 | from __future__ import absolute_import | 
|  | 8 | from __future__ import division | 
|  | 9 | from __future__ import print_function | 
|  | 10 |  | 
|  | 11 | import pytest | 
|  | 12 |  | 
|  | 13 |  | 
|  | 14 | def pytest_addoption(parser): | 
|  | 15 | """Add extra pytest options.""" | 
|  | 16 | parser.addoption("--skipslow", action="store_true", | 
|  | 17 | default=False, help="Skip slow tests") | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | def pytest_collection_modifyitems(config, items): | 
|  | 21 | """Modify tests to remove slow tests if --skipslow was passed.""" | 
| Allen Li | 2678d36 | 2017-10-11 16:59:07 -0700 | [diff] [blame^] | 22 | if config.getoption("--skipslow"):  # pragma: no cover | 
| Allen Li | 8c4d01b | 2017-09-22 13:53:16 -0700 | [diff] [blame] | 23 | skip_slow = pytest.mark.skip(reason="--skipslow option was passed") | 
|  | 24 | for item in items: | 
|  | 25 | if "slow" in item.keywords: | 
|  | 26 | item.add_marker(skip_slow) |