~mvo/click/more-integration-tests3

« back to all changes in this revision

Viewing changes to click/tests/integration/helpers.py

  • Committer: Michael Vogt
  • Date: 2014-09-05 09:04:33 UTC
  • mfrom: (489.1.20 devel)
  • Revision ID: michael.vogt@ubuntu.com-20140905090433-d5dyacbc1ooolfhd
mergedĀ lp:click/devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import unittest
28
28
 
29
29
 
30
 
def is_root():
31
 
    return os.getuid() == 0
32
 
 
33
 
 
34
 
def has_network():
35
 
    return subprocess.call(
36
 
        ["ping", "-c1", "archive.ubuntu.com"]) == 0
 
30
def require_root():
 
31
    if os.getuid() != 0:
 
32
        raise unittest.SkipTest("This test needs to run as root")
 
33
 
 
34
 
 
35
def require_network():
 
36
    try:
 
37
        if subprocess.call(["ping", "-c1", "archive.ubuntu.com"]) != 0:
 
38
            raise unittest.SkipTest("Need network")
 
39
    except Exception:
 
40
        pass
37
41
 
38
42
 
39
43
@contextlib.contextmanager
59
63
 
60
64
    @classmethod
61
65
    def setUpClass(cls):
 
66
        if "TEST_INTEGRATION" not in os.environ:
 
67
            raise unittest.SkipTest("Skipping integration tests")
62
68
        cls.click_binary = os.environ.get("CLICK_BINARY", "/usr/bin/click")
63
69
 
64
70
    def setUp(self):