diff --git a/pythonFiles/tests/__init__.py b/pythonFiles/tests/__init__.py index e69de29bb2d1..5b7f7a925cc0 100644 --- a/pythonFiles/tests/__init__.py +++ b/pythonFiles/tests/__init__.py @@ -0,0 +1,2 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. diff --git a/pythonFiles/tests/__main__.py b/pythonFiles/tests/__main__.py index 06d6586941e2..e6fa8c12602b 100644 --- a/pythonFiles/tests/__main__.py +++ b/pythonFiles/tests/__main__.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + import os.path import sys diff --git a/pythonFiles/tests/run_all.py b/pythonFiles/tests/run_all.py index cf85310dbd22..1b798db648bb 100644 --- a/pythonFiles/tests/run_all.py +++ b/pythonFiles/tests/run_all.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + # Replace the "." entry. import os.path import sys diff --git a/pythonFiles/tests/test_normalize_for_interpreter.py b/pythonFiles/tests/test_normalize_for_interpreter.py new file mode 100644 index 000000000000..a54bd9802e8b --- /dev/null +++ b/pythonFiles/tests/test_normalize_for_interpreter.py @@ -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 diff --git a/pythonFiles/tests/testing_tools/__init__.py b/pythonFiles/tests/testing_tools/__init__.py index e69de29bb2d1..5b7f7a925cc0 100644 --- a/pythonFiles/tests/testing_tools/__init__.py +++ b/pythonFiles/tests/testing_tools/__init__.py @@ -0,0 +1,2 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. diff --git a/pythonFiles/tests/testing_tools/adapter/__init__.py b/pythonFiles/tests/testing_tools/adapter/__init__.py index e69de29bb2d1..5b7f7a925cc0 100644 --- a/pythonFiles/tests/testing_tools/adapter/__init__.py +++ b/pythonFiles/tests/testing_tools/adapter/__init__.py @@ -0,0 +1,2 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. diff --git a/pythonFiles/tests/testing_tools/adapter/test___main__.py b/pythonFiles/tests/testing_tools/adapter/test___main__.py index 19f42a466941..b5d743e31101 100644 --- a/pythonFiles/tests/testing_tools/adapter/test___main__.py +++ b/pythonFiles/tests/testing_tools/adapter/test___main__.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + import unittest from ...util import Stub, StubProxy diff --git a/pythonFiles/tests/testing_tools/adapter/test_pytest.py b/pythonFiles/tests/testing_tools/adapter/test_pytest.py index 4f634b7ec8d5..2602d9d05af0 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_pytest.py +++ b/pythonFiles/tests/testing_tools/adapter/test_pytest.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + import os.path import unittest diff --git a/pythonFiles/tests/testing_tools/adapter/test_report.py b/pythonFiles/tests/testing_tools/adapter/test_report.py index 89c2f3b7568e..2a844b50d4e8 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_report.py +++ b/pythonFiles/tests/testing_tools/adapter/test_report.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + import json import os.path import unittest diff --git a/pythonFiles/tests/util.py b/pythonFiles/tests/util.py index fade5261b2f3..2a6dd02552a4 100644 --- a/pythonFiles/tests/util.py +++ b/pythonFiles/tests/util.py @@ -1,3 +1,5 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. class Stub(object):