File: context.py

package info (click to toggle)
python-invoke 1.4.1%2Bds-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,704 kB
  • sloc: python: 11,377; makefile: 18; sh: 12
file content (19 lines) | stat: -rw-r--r-- 667 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os

from pytest import skip

from invoke import Context, Config


class Context_:
    class sudo:
        def base_case(self):
            # NOTE: Assumes a user whose password is 'mypass' has been created
            # & added to passworded (not passwordless) sudo configuration; and
            # that this user is the one running the test suite. Only for
            # running on Travis, basically.
            if not os.environ.get("TRAVIS", False):
                skip()
            config = Config({"sudo": {"password": "mypass"}})
            result = Context(config=config).sudo("whoami", hide=True)
            assert result.stdout.strip() == "root"