Debian Codegraph @

tests/plugins/travis.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2013 Sebastian Wiesner <[email protected]>
3
4 # This library is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU Lesser General Public License as published by the
6 # Free Software Foundation; either version 2.1 of the License, or (at your
7 # option) any later version.
8
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12 # for more details.
13
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 """
18 plugins.travis
19 ==============
20
21 Support for Travis CI.
22 """
23
24 # isort: STDLIB
25 import os
26
27 # isort: THIRDPARTY
28 import pytest
29
30
31 def is_on_travis_ci():
32 """Determine whether the tests run on Travis CI.
33
34 Return ``True``, if so, or ``False`` otherwise.
35
36 """
37 return os.environ.get("TRAVIS", "") == "true"
38
39
40 EXPOSED_FUNCTIONS = [is_on_travis_ci]
41
42
43 def pytest_configure():
44 for f in EXPOSED_FUNCTIONS:
45 setattr(pytest, f.__name__, f)
46
47
48 def pytest_runtest_setup(item):
49 if not hasattr(item, "obj"):
50 return
51 marker = getattr(item.obj, "not_on_travis", None)
52 if marker and is_on_travis_ci():
53 pytest.skip("Test must not run on Travis CI")