@@ -123,11 +123,10 @@ def run_stubtest(
123
123
output = io .StringIO ()
124
124
with contextlib .redirect_stdout (output ):
125
125
test_stubs (parse_options ([TEST_MODULE_NAME ] + options ), use_builtins_fixtures = True )
126
- # remove cwd as it's not available from outside
127
- return (
126
+ return remove_color_code (
128
127
output .getvalue ()
129
- . replace ( os . path . realpath ( tmp_dir ) + os . sep , "" )
130
- .replace (tmp_dir + os .sep , "" )
128
+ # remove cwd as it's not available from outside
129
+ .replace (os . path . realpath ( tmp_dir ) + os . sep , "" ). replace ( tmp_dir + os .sep , "" )
131
130
)
132
131
133
132
@@ -1866,7 +1865,7 @@ def test_output(self) -> None:
1866
1865
f"Runtime: in file { TEST_MODULE_NAME } .py:1\n def (num, text)\n \n "
1867
1866
"Found 1 error (checked 1 module)\n "
1868
1867
)
1869
- assert remove_color_code ( output ) == expected
1868
+ assert output == expected
1870
1869
1871
1870
output = run_stubtest (
1872
1871
stub = "def bad(number: int, text: str) -> None: ..." ,
@@ -1877,7 +1876,7 @@ def test_output(self) -> None:
1877
1876
"{}.bad is inconsistent, "
1878
1877
'stub argument "number" differs from runtime argument "num"\n ' .format (TEST_MODULE_NAME )
1879
1878
)
1880
- assert remove_color_code ( output ) == expected
1879
+ assert output == expected
1881
1880
1882
1881
def test_ignore_flags (self ) -> None :
1883
1882
output = run_stubtest (
@@ -1956,13 +1955,13 @@ def also_bad(asdf): pass
1956
1955
1957
1956
def test_mypy_build (self ) -> None :
1958
1957
output = run_stubtest (stub = "+" , runtime = "" , options = [])
1959
- assert remove_color_code ( output ) == (
1958
+ assert output == (
1960
1959
"error: not checking stubs due to failed mypy compile:\n {}.pyi:1: "
1961
1960
"error: invalid syntax [syntax]\n " .format (TEST_MODULE_NAME )
1962
1961
)
1963
1962
1964
1963
output = run_stubtest (stub = "def f(): ...\n def f(): ..." , runtime = "" , options = [])
1965
- assert remove_color_code ( output ) == (
1964
+ assert output == (
1966
1965
"error: not checking stubs due to mypy build errors:\n {}.pyi:2: "
1967
1966
'error: Name "f" already defined on line 1 [no-redef]\n ' .format (TEST_MODULE_NAME )
1968
1967
)
@@ -2019,7 +2018,7 @@ def test_config_file(self) -> None:
2019
2018
stub = "from decimal import Decimal\n temp: Decimal\n "
2020
2019
config_file = f"[mypy]\n plugins={ root_dir } /test-data/unit/plugins/decimal_to_int.py\n "
2021
2020
output = run_stubtest (stub = stub , runtime = runtime , options = [])
2022
- assert remove_color_code ( output ) == (
2021
+ assert output == (
2023
2022
f"error: { TEST_MODULE_NAME } .temp variable differs from runtime type Literal[5]\n "
2024
2023
f"Stub: in file { TEST_MODULE_NAME } .pyi:2\n _decimal.Decimal\n Runtime:\n 5\n \n "
2025
2024
"Found 1 error (checked 1 module)\n "
0 commit comments