File: test_zsh.py

package info (click to toggle)
python-userpath 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: python: 771; makefile: 21; sh: 16
file content (65 lines) | stat: -rw-r--r-- 2,475 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pytest
import userpath

from .utils import SKIP_WINDOWS_CI, get_random_path

SHELL_NAME = 'zsh'

pytestmark = [SKIP_WINDOWS_CI, pytest.mark.zsh]


@pytest.mark.usefixtures('shell_test')
class TestDebian(object):
    DOCKERFILE = 'debian'

    def test_prepend(self, request, shell_test):
        if shell_test is None:
            location = get_random_path()
            assert not userpath.in_current_path(location)
            assert userpath.prepend(location, check=True)
            assert userpath.in_new_path(location)
            assert userpath.need_shell_restart(location)
        else:
            process = shell_test(request.node.name)
            stdout, stderr = process.communicate()

            assert process.returncode == 0, (stdout + stderr).decode('utf-8')

    def test_prepend_multiple(self, request, shell_test):
        if shell_test is None:
            locations = [get_random_path(), get_random_path()]
            assert not userpath.in_current_path(locations)
            assert userpath.prepend(locations, check=True)
            assert userpath.in_new_path(locations)
            assert userpath.need_shell_restart(locations)
        else:
            process = shell_test(request.node.name)
            stdout, stderr = process.communicate()

            assert process.returncode == 0, (stdout + stderr).decode('utf-8')

    def test_append(self, request, shell_test):
        if shell_test is None:
            location = get_random_path()
            assert not userpath.in_current_path(location)
            assert userpath.append(location, check=True)
            assert userpath.in_new_path(location)
            assert userpath.need_shell_restart(location)
        else:
            process = shell_test(request.node.name)
            stdout, stderr = process.communicate()

            assert process.returncode == 0, (stdout + stderr).decode('utf-8')

    def test_append_multiple(self, request, shell_test):
        if shell_test is None:
            locations = [get_random_path(), get_random_path()]
            assert not userpath.in_current_path(locations)
            assert userpath.append(locations, check=True)
            assert userpath.in_new_path(locations)
            assert userpath.need_shell_restart(locations)
        else:
            process = shell_test(request.node.name)
            stdout, stderr = process.communicate()

            assert process.returncode == 0, (stdout + stderr).decode('utf-8')