@@ -123,11 +123,10 @@ def run_stubtest(
123123 output = io .StringIO ()
124124 with contextlib .redirect_stdout (output ):
125125 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 (
128127 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 , "" )
131130 )
132131
133132
@@ -1866,7 +1865,7 @@ def test_output(self) -> None:
18661865 f"Runtime: in file { TEST_MODULE_NAME } .py:1\n def (num, text)\n \n "
18671866 "Found 1 error (checked 1 module)\n "
18681867 )
1869- assert remove_color_code ( output ) == expected
1868+ assert output == expected
18701869
18711870 output = run_stubtest (
18721871 stub = "def bad(number: int, text: str) -> None: ..." ,
@@ -1877,7 +1876,7 @@ def test_output(self) -> None:
18771876 "{}.bad is inconsistent, "
18781877 'stub argument "number" differs from runtime argument "num"\n ' .format (TEST_MODULE_NAME )
18791878 )
1880- assert remove_color_code ( output ) == expected
1879+ assert output == expected
18811880
18821881 def test_ignore_flags (self ) -> None :
18831882 output = run_stubtest (
@@ -1956,13 +1955,13 @@ def also_bad(asdf): pass
19561955
19571956 def test_mypy_build (self ) -> None :
19581957 output = run_stubtest (stub = "+" , runtime = "" , options = [])
1959- assert remove_color_code ( output ) == (
1958+ assert output == (
19601959 "error: not checking stubs due to failed mypy compile:\n {}.pyi:1: "
19611960 "error: invalid syntax [syntax]\n " .format (TEST_MODULE_NAME )
19621961 )
19631962
19641963 output = run_stubtest (stub = "def f(): ...\n def f(): ..." , runtime = "" , options = [])
1965- assert remove_color_code ( output ) == (
1964+ assert output == (
19661965 "error: not checking stubs due to mypy build errors:\n {}.pyi:2: "
19671966 'error: Name "f" already defined on line 1 [no-redef]\n ' .format (TEST_MODULE_NAME )
19681967 )
@@ -2019,7 +2018,7 @@ def test_config_file(self) -> None:
20192018 stub = "from decimal import Decimal\n temp: Decimal\n "
20202019 config_file = f"[mypy]\n plugins={ root_dir } /test-data/unit/plugins/decimal_to_int.py\n "
20212020 output = run_stubtest (stub = stub , runtime = runtime , options = [])
2022- assert remove_color_code ( output ) == (
2021+ assert output == (
20232022 f"error: { TEST_MODULE_NAME } .temp variable differs from runtime type Literal[5]\n "
20242023 f"Stub: in file { TEST_MODULE_NAME } .pyi:2\n _decimal.Decimal\n Runtime:\n 5\n \n "
20252024 "Found 1 error (checked 1 module)\n "
0 commit comments