Skip to content

Make tests use \[ to escape brackets instead of [[ #7521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2019
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
4 changes: 2 additions & 2 deletions mypy/test/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def parse_test_data(raw_data: str, name: str) -> List[TestItem]:
while i < len(lines):
s = lines[i].strip()

if lines[i].startswith('[') and s.endswith(']') and not s.startswith('[['):
if lines[i].startswith('[') and s.endswith(']'):
if id:
data = collapse_line_continuation(data)
data = strip_list(data)
Expand All @@ -437,7 +437,7 @@ def parse_test_data(raw_data: str, name: str) -> List[TestItem]:
arg = id[id.index(' ') + 1:]
id = id[:id.index(' ')]
data = []
elif lines[i].startswith('[['):
elif lines[i].startswith('\\['):
data.append(lines[i][1:])
elif not lines[i].startswith('--'):
data.append(lines[i])
Expand Down
5 changes: 2 additions & 3 deletions mypyc/test-data/run.test
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,8 @@ from native import primes
print(primes(3))
print(primes(13))
[out]
[[0, 0, 1, 1]
[[0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1]
-- argh ]]
\[0, 0, 1, 1]
\[0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1]


[case testListPrims]
Expand Down
80 changes: 40 additions & 40 deletions test-data/unit/check-custom-plugin.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
def f() -> str: ...
reveal_type(f()) # N: Revealed type is 'builtins.int'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/fnplugin.py

[case testFunctionPlugin]
# flags: --config-file tmp/mypy.ini
def f() -> str: ...
reveal_type(f()) # N: Revealed type is 'builtins.int'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=fnplugin

[case testFunctionPluginFullnameIsNotNone]
Expand All @@ -27,7 +27,7 @@ T = TypeVar('T')
def g(x: T) -> T: return x # This strips out the name of a callable
g(f)()
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/fnplugin.py

[case testTwoPlugins]
Expand All @@ -39,7 +39,7 @@ reveal_type(f()) # N: Revealed type is 'builtins.int'
reveal_type(g()) # N: Revealed type is 'builtins.str'
reveal_type(h()) # N: Revealed type is 'Any'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/fnplugin.py,
<ROOT>/test-data/unit/plugins/plugin2.py

Expand All @@ -52,13 +52,13 @@ reveal_type(f()) # N: Revealed type is 'builtins.int'
reveal_type(g()) # N: Revealed type is 'builtins.str'
reveal_type(h()) # N: Revealed type is 'Any'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/fnplugin.py, plugin2

[case testMissingPluginFile]
# flags: --config-file tmp/mypy.ini
[file mypy.ini]
[[mypy]
\[mypy]
plugins=missing.py
[out]
tmp/mypy.ini:2: error: Can't find plugin 'tmp/missing.py'
Expand All @@ -67,19 +67,19 @@ tmp/mypy.ini:2: error: Can't find plugin 'tmp/missing.py'
[case testMissingPlugin]
# flags: --config-file tmp/mypy.ini
[file mypy.ini]
[[mypy]
\[mypy]
plugins=missing
[out]
tmp/mypy.ini:2: error: Error importing plugin 'missing'

[case testMultipleSectionsDefinePlugin]
# flags: --config-file tmp/mypy.ini
[file mypy.ini]
[[acme]
\[acme]
plugins=acmeplugin
[[mypy]
\[mypy]
plugins=missing.py
[[another]
\[another]
plugins=another_plugin
[out]
tmp/mypy.ini:4: error: Can't find plugin 'tmp/missing.py'
Expand All @@ -88,7 +88,7 @@ tmp/mypy.ini:4: error: Can't find plugin 'tmp/missing.py'
[case testInvalidPluginExtension]
# flags: --config-file tmp/mypy.ini
[file mypy.ini]
[[mypy]
\[mypy]
plugins=dir/badext.pyi
[file dir/badext.pyi]
[out]
Expand All @@ -97,7 +97,7 @@ tmp/mypy.ini:2: error: Plugin 'badext.pyi' does not have a .py extension
[case testMissingPluginEntryPoint]
# flags: --config-file tmp/mypy.ini
[file mypy.ini]
[[mypy]
\[mypy]
plugins = <ROOT>/test-data/unit/plugins/noentry.py
[out]
tmp/mypy.ini:2: error: Plugin '<ROOT>/test-data/unit/plugins/noentry.py' does not define entry point function "plugin"
Expand All @@ -107,23 +107,23 @@ tmp/mypy.ini:2: error: Plugin '<ROOT>/test-data/unit/plugins/noentry.py' does no
def f() -> str: ...
reveal_type(f()) # N: Revealed type is 'builtins.int'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/customentry.py:register

[case testCustomPluginEntryPoint]
# flags: --config-file tmp/mypy.ini
def f() -> str: ...
reveal_type(f()) # N: Revealed type is 'builtins.int'
[file mypy.ini]
[[mypy]
\[mypy]
plugins=customentry:register

[case testInvalidPluginEntryPointReturnValue]
# flags: --config-file tmp/mypy.ini
def f(): pass
f()
[file mypy.ini]
[[mypy]
\[mypy]

plugins=<ROOT>/test-data/unit/plugins/badreturn.py
[out]
Expand All @@ -134,7 +134,7 @@ tmp/mypy.ini:3: error: Type object expected as the return value of "plugin"; got
def f(): pass
f()
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/badreturn2.py
[out]
tmp/mypy.ini:2: error: Return value of "plugin" must be a subclass of "mypy.plugin.Plugin" (in <ROOT>/test-data/unit/plugins/badreturn2.py)
Expand All @@ -157,7 +157,7 @@ class Signal(Generic[T]):

class DerivedSignal(Signal[T]): ...
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/attrhook.py

[case testAttributeHookPluginForDynamicClass]
Expand All @@ -182,7 +182,7 @@ class Magic:
class DerivedMagic(Magic): ...

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/attrhook2.py

[case testTypeAnalyzeHookPlugin]
Expand All @@ -200,7 +200,7 @@ T = TypeVar('T', bound=Callable[..., None])
class Signal(Generic[T]):
__call__: Callable[..., None]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/type_anal_hook.py
[builtins fixtures/dict.pyi]

Expand Down Expand Up @@ -237,7 +237,7 @@ class AttrInt(Attr[int]):
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/class_callable.py
[builtins fixtures/bool.pyi]
[out]
Expand All @@ -256,7 +256,7 @@ from typing import Callable
def decorator1() -> Callable[..., Callable[..., int]]: pass
def decorator2() -> Callable[..., Callable[..., int]]: pass
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/named_callable.py

[case testFunctionMethodContextsHasArgNames]
Expand Down Expand Up @@ -284,7 +284,7 @@ def func(classname: str, arg1: Any, arg2: Any) -> Any:
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py
[builtins fixtures/classmethod.pyi]

Expand Down Expand Up @@ -313,7 +313,7 @@ def func(classname: str, arg1: Any, arg2: Any) -> Any:
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py
[builtins fixtures/classmethod.pyi]

Expand All @@ -335,7 +335,7 @@ class Outer:
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py

[case testFunctionMethodContextsHasArgNamesUnfilledArguments]
Expand All @@ -358,7 +358,7 @@ def func_unfilled(classname: str, arg1: Any = None, arg2: Any = None) -> Any:
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py

[case testFunctionMethodContextsHasArgNamesStarExpressions]
Expand All @@ -382,7 +382,7 @@ def func_star_expr(classname: str, *args, **kwargs) -> Any:
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py
[builtins fixtures/dict.pyi]

Expand All @@ -406,7 +406,7 @@ class ClassChild(Base):
pass

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_names.py
[builtins fixtures/classmethod.pyi]

Expand Down Expand Up @@ -435,7 +435,7 @@ for x in foo:
reveal_type(x) # N: Revealed type is 'builtins.int*'

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/method_sig_hook.py

[case testMethodSignatureHookNamesFullyQualified]
Expand All @@ -459,7 +459,7 @@ reveal_type(FullyQualifiedTestClass().instance_method()) # N: Revealed type is '
reveal_type(FullyQualifiedTestNamedTuple('')._asdict()) # N: Revealed type is 'builtins.int'

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/fully_qualified_test_hook.py
[builtins fixtures/classmethod.pyi]

Expand All @@ -486,7 +486,7 @@ class Column(Generic[T]): ...
class Instr(Generic[T]): ...

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/dyn_class.py

[case testDynamicClassPluginNegatives]
Expand All @@ -513,7 +513,7 @@ class Column(Generic[T]): ...
class Instr(Generic[T]): ...

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/dyn_class.py

[case testBaseClassPluginHookWorksIncremental]
Expand All @@ -539,7 +539,7 @@ from typing import Any
def declarative_base() -> Any: ...

[file mypy.ini]
[[mypy]
\[mypy]
python_version=3.6
plugins=<ROOT>/test-data/unit/plugins/common_api_incremental.py
[out]
Expand All @@ -556,7 +556,7 @@ class Class:
Class().method(1, *[2], **{'a': 1}) # E: [[0, 2], [4]]
[builtins fixtures/dict.pyi]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_kinds.py

[case testArgKindsFunction]
Expand All @@ -567,7 +567,7 @@ def func(*args, **kwargs):
func(1, 2, [3, 4], *[5, 6, 7], **{'a': 1}) # E: [[0, 0, 0, 2], [4]]
[builtins fixtures/dict.pyi]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/arg_kinds.py

[case testHookCallableInstance]
Expand All @@ -582,7 +582,7 @@ instance = Class(3.14)
reveal_type(instance(2)) # N: Revealed type is 'builtins.float*'

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/callable_instance.py

[case testGetMethodHooksOnUnions]
Expand All @@ -604,7 +604,7 @@ else:

[builtins fixtures/isinstancelist.pyi]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/union_method.py

[case testGetMethodHooksOnUnionsStrictOptional]
Expand All @@ -626,7 +626,7 @@ else:

[builtins fixtures/isinstancelist.pyi]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/union_method.py

[case testGetMethodHooksOnUnionsSpecial]
Expand All @@ -643,7 +643,7 @@ reveal_type(x[int()]) # N: Revealed type is 'builtins.int'

[builtins fixtures/isinstancelist.pyi]
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/union_method.py

[case testPluginDependencies]
Expand All @@ -656,12 +656,12 @@ plugins=<ROOT>/test-data/unit/plugins/union_method.py
1 + 'lol' # E: Unsupported operand types for + ("int" and "str")

[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/depshook.py

[case testCustomizeMroTrivial]
# flags: --config-file tmp/mypy.ini
class A: pass
[file mypy.ini]
[[mypy]
\[mypy]
plugins=<ROOT>/test-data/unit/plugins/customize_mro.py
Loading