Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pythonFiles/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
3 changes: 3 additions & 0 deletions pythonFiles/tests/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import os.path
import sys

Expand Down
3 changes: 3 additions & 0 deletions pythonFiles/tests/run_all.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Replace the "." entry.
import os.path
import sys
Expand Down
95 changes: 95 additions & 0 deletions pythonFiles/tests/test_normalize_for_interpreter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import pytest
import textwrap

import normalizeForInterpreter


class TestNormalizationScript(object):
"""Basic unit tests for the normalization script."""

def test_basicNormalization(self, capsys):
src = 'print("this is a test")'
normalizeForInterpreter.normalize_lines(src)
captured = capsys.readouterr()
assert captured.out == src

def test_moreThanOneLine(self, capsys):
src = textwrap.dedent("""\
# Some rando comment

def show_something():
print("Something")
"""
)
normalizeForInterpreter.normalize_lines(src)
captured = capsys.readouterr()
assert captured.out == src

def test_withHangingIndent(self, capsys):
src = textwrap.dedent("""\
x = 22
y = 30
z = -10
result = x + y + z

if result == 42:
print("The answer to life, the universe, and everything")
"""
)
normalizeForInterpreter.normalize_lines(src)
captured = capsys.readouterr()
assert captured.out == src

def test_clearOutExtraneousNewlines(self, capsys):
src = textwrap.dedent("""\
value_x = 22

value_y = 30

value_z = -10

print(value_x + value_y + value_z)

"""
)
expectedResult = textwrap.dedent("""\
value_x = 22
value_y = 30
value_z = -10
print(value_x + value_y + value_z)

"""
)
normalizeForInterpreter.normalize_lines(src)
result = capsys.readouterr()
assert result.out == expectedResult

def test_clearOutExtraLinesAndWhitespace(self, capsys):
src = textwrap.dedent("""\
if True:
x = 22

y = 30

z = -10

print(x + y + z)

"""
)
expectedResult = textwrap.dedent("""\
if True:
x = 22
y = 30
z = -10

print(x + y + z)

"""
)
normalizeForInterpreter.normalize_lines(src)
result = capsys.readouterr()
assert result.out == expectedResult
2 changes: 2 additions & 0 deletions pythonFiles/tests/testing_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
2 changes: 2 additions & 0 deletions pythonFiles/tests/testing_tools/adapter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
3 changes: 3 additions & 0 deletions pythonFiles/tests/testing_tools/adapter/test___main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import unittest

from ...util import Stub, StubProxy
Expand Down
3 changes: 3 additions & 0 deletions pythonFiles/tests/testing_tools/adapter/test_pytest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import os.path
import unittest

Expand Down
3 changes: 3 additions & 0 deletions pythonFiles/tests/testing_tools/adapter/test_report.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import json
import os.path
import unittest
Expand Down
2 changes: 2 additions & 0 deletions pythonFiles/tests/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

class Stub(object):

Expand Down