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 7from __future__ import absolute_import 8from __future__ import division 9from __future__ import print_function 10 11import pytest 12 13 14def pytest_addoption(parser): 15 """Add extra pytest options.""" 16 parser.addoption("--skipslow", action="store_true", 17 default=False, help="Skip slow tests") 18 19 20def pytest_collection_modifyitems(config, items): 21 """Modify tests to remove slow tests if --skipslow was passed.""" 22 if config.getoption("--skipslow"): # pragma: no cover 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) 27