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 — Add test coverage: normalizeForInterpreter.py (#4680) · rdrey/vscode-python@225ca2b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pythonFiles/tests
    • __init__.py
    • __main__.py
    • run_all.py
    • test_normalize_for_interpreter.py
    • testing_tools
      • __init__.py
      • adapter
        • __init__.py
        • test___main__.py
        • test_pytest.py
        • test_report.py
    • util.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pythonFiles/tests/__init__.py‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
Collapse file

‎pythonFiles/tests/__main__.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/__main__.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
import os.path
25
import sys
36

Collapse file

‎pythonFiles/tests/run_all.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/run_all.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
# Replace the "." entry.
25
import os.path
36
import sys
Collapse file

‎pythonFiles/tests/test_normalize_for_interpreter.py‎

Copy file name to clipboard
+95Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
import pytest
5+
import textwrap
6+
7+
import normalizeForInterpreter
8+
9+
10+
class TestNormalizationScript(object):
11+
"""Basic unit tests for the normalization script."""
12+
13+
def test_basicNormalization(self, capsys):
14+
src = 'print("this is a test")'
15+
normalizeForInterpreter.normalize_lines(src)
16+
captured = capsys.readouterr()
17+
assert captured.out == src
18+
19+
def test_moreThanOneLine(self, capsys):
20+
src = textwrap.dedent("""\
21+
# Some rando comment
22+
23+
def show_something():
24+
print("Something")
25+
"""
26+
)
27+
normalizeForInterpreter.normalize_lines(src)
28+
captured = capsys.readouterr()
29+
assert captured.out == src
30+
31+
def test_withHangingIndent(self, capsys):
32+
src = textwrap.dedent("""\
33+
x = 22
34+
y = 30
35+
z = -10
36+
result = x + y + z
37+
38+
if result == 42:
39+
print("The answer to life, the universe, and everything")
40+
"""
41+
)
42+
normalizeForInterpreter.normalize_lines(src)
43+
captured = capsys.readouterr()
44+
assert captured.out == src
45+
46+
def test_clearOutExtraneousNewlines(self, capsys):
47+
src = textwrap.dedent("""\
48+
value_x = 22
49+
50+
value_y = 30
51+
52+
value_z = -10
53+
54+
print(value_x + value_y + value_z)
55+
56+
"""
57+
)
58+
expectedResult = textwrap.dedent("""\
59+
value_x = 22
60+
value_y = 30
61+
value_z = -10
62+
print(value_x + value_y + value_z)
63+
64+
"""
65+
)
66+
normalizeForInterpreter.normalize_lines(src)
67+
result = capsys.readouterr()
68+
assert result.out == expectedResult
69+
70+
def test_clearOutExtraLinesAndWhitespace(self, capsys):
71+
src = textwrap.dedent("""\
72+
if True:
73+
x = 22
74+
75+
y = 30
76+
77+
z = -10
78+
79+
print(x + y + z)
80+
81+
"""
82+
)
83+
expectedResult = textwrap.dedent("""\
84+
if True:
85+
x = 22
86+
y = 30
87+
z = -10
88+
89+
print(x + y + z)
90+
91+
"""
92+
)
93+
normalizeForInterpreter.normalize_lines(src)
94+
result = capsys.readouterr()
95+
assert result.out == expectedResult
Collapse file

‎pythonFiles/tests/testing_tools/__init__.py‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
Collapse file

‎pythonFiles/tests/testing_tools/adapter/__init__.py‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
Collapse file

‎pythonFiles/tests/testing_tools/adapter/test___main__.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/test___main__.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
import unittest
25

36
from ...util import Stub, StubProxy
Collapse file

‎pythonFiles/tests/testing_tools/adapter/test_pytest.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/test_pytest.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
import os.path
25
import unittest
36

Collapse file

‎pythonFiles/tests/testing_tools/adapter/test_report.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/test_report.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
import json
25
import os.path
36
import unittest
Collapse file

‎pythonFiles/tests/util.py‎

Copy file name to clipboardExpand all lines: pythonFiles/tests/util.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
13

24
class Stub(object):
35

0 commit comments

Comments
0 (0)
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.