GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python/tests/test_shell.py at master · roustask/python

Expand file tree

/

test_shell.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
116 lines (91 loc) · 3.3 KB
/

test_shell.py

Copy path

File metadata and controls

116 lines (91 loc) · 3.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pytest
from danger_python.exceptions import DangerfileException, SystemConfigurationException
from danger_python.shell import (
build_danger_command,
execute_dangerfile,
resolve_danger_path,
)
@pytest.mark.parametrize("danger_js_path", ["/usr/bin/fake-danger-js \n \r"])
@pytest.mark.usefixtures("run_subprocess")
def test_danger_path_can_be_resolved_if_present():
"""
Test that danger-js path can be resolved.
"""
resolved_path = resolve_danger_path()
assert resolved_path == "/usr/bin/fake-danger-js"
@pytest.mark.usefixtures("run_subprocess")
def test_danger_path_resolver_throws_an_error_if_not_present():
"""
Test that danger-js path resolver throws an error if not present.
"""
with pytest.raises(SystemConfigurationException) as config_exc:
resolve_danger_path()
assert config_exc.match("danger-js not found in PATH")
@pytest.mark.parametrize("danger_js_path", ["/usr/bin/danger-js \n \r"])
@pytest.mark.usefixtures("run_subprocess")
def test_build_danger_command_works():
"""
Test that building correct danger command works.
"""
first_command = build_danger_command(["pr", "https://pr.url"])
second_command = build_danger_command(["ci", "-i", "2020", "-t"])
assert first_command == [
"/usr/bin/danger-js",
"pr",
"https://pr.url",
"-p",
"danger-python",
"-u",
]
assert second_command == [
"/usr/bin/danger-js",
"ci",
"-i",
"2020",
"-t",
"-p",
"danger-python",
"-u",
]
@pytest.mark.usefixtures("danger")
def test_dangerfile_executor_formats_syntax_error_correctly():
"""
Test that dangerfile executor formats the SyntaxError correctly.
"""
dangerfile = "a = 2\n" "b = 8\n" "This is not a valid Python syntax\n"
with pytest.raises(DangerfileException) as danger_exc:
execute_dangerfile(dangerfile)
expected_message = (
"There was an error when executing dangerfile.py:\n"
"SyntaxError at line 3: invalid syntax\n\n"
"Stacktrace:\n"
)
assert str(danger_exc.value).startswith(expected_message)
@pytest.mark.usefixtures("danger")
def test_dangerfile_executor_formats_name_error_correctly():
"""
Test that dangerfile executor formats the NameError correctly.
"""
dangerfile = "a = 2\n" "c += 8\n" "b = 12\n"
with pytest.raises(DangerfileException) as danger_exc:
execute_dangerfile(dangerfile)
expected_message = (
"There was an error when executing dangerfile.py:\n"
"NameError at line 2: name 'c' is not defined\n\n"
"Stacktrace:\n"
)
assert str(danger_exc.value).startswith(expected_message)
@pytest.mark.usefixtures("danger")
def test_dangerfile_executor_formats_nester_error_correctly():
"""
Test that dangerfile executor formats the nested error correctly.
"""
dangerfile = "import json\n" """json.loads('this is not a json')"""
with pytest.raises(DangerfileException) as danger_exc:
execute_dangerfile(dangerfile)
expected_message = (
"There was an error when executing dangerfile.py:\n"
"JSONDecodeError at line 2: Expecting value: line 1 column 1 (char 0)\n\n"
"Stacktrace:\n"
)
assert str(danger_exc.value).startswith(expected_message)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.