From c8036250d1f8f67411b95b70281bdb889b85dd10 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:13:16 +0200 Subject: [PATCH 01/13] .startswith('/') -> .is_absolute() --- devtools/debug.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/devtools/debug.py b/devtools/debug.py index b9f7182..c9a8aa5 100644 --- a/devtools/debug.py +++ b/devtools/debug.py @@ -1,5 +1,6 @@ import os import sys +from pathlib import Path from .ansi import sformat from .prettier import PrettyFormat @@ -141,15 +142,14 @@ def _process(self, args, kwargs) -> DebugOutput: warning=self._show_warnings and 'error parsing code, call stack too shallow', ) - filename = call_frame.f_code.co_filename function = call_frame.f_code.co_name - if filename.startswith('/'): - # make the path relative - from pathlib import Path + path = Path(call_frame.f_code.co_filename) + if path.is_absolute(): + # make the path relative cwd = Path('.').resolve() try: - filename = str(Path(filename).relative_to(cwd)) + path = path.relative_to(cwd) except ValueError: # happens if filename path is not within CWD pass @@ -173,7 +173,7 @@ def _process(self, args, kwargs) -> DebugOutput: arguments = list(self._process_args(ex, args, kwargs)) return self.output_class( - filename=filename, + filename=str(path), lineno=lineno, frame=function, arguments=arguments, From 68224eafdf9c8fbb8d5fdddfb7a2e65cfebc195e Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:23:41 +0200 Subject: [PATCH 02/13] normalise_output function in tests --- tests/test_expr_render.py | 38 +++++++++++++++++++------------------- tests/test_main.py | 34 +++++++++++++++++----------------- tests/utils.py | 8 ++++++++ 3 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 tests/utils.py diff --git a/tests/test_expr_render.py b/tests/test_expr_render.py index 7d66268..10400bb 100644 --- a/tests/test_expr_render.py +++ b/tests/test_expr_render.py @@ -5,6 +5,7 @@ import pytest from devtools import Debug, debug +from tests.utils import normalise_output def foobar(a, b, c): @@ -15,7 +16,7 @@ def foobar(a, b, c): def test_simple(): a = [1, 2, 3] v = debug.format(len(a)) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) # print(s) assert ( 'tests/test_expr_render.py: test_simple\n' @@ -27,7 +28,7 @@ def test_simple(): def test_subscription(): a = {1: 2} v = debug.format(a[1]) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert ( 'tests/test_expr_render.py: test_subscription\n' ' a[1]: 2 (int)' @@ -49,8 +50,7 @@ def test_exotic_types(): {a: a + 1 for a in aa}, (a for a in aa), ) - s = re.sub(r':\d{2,}', ':', str(v)) - s = re.sub(r'(at 0x)\w+', r'\1', s) + s = normalise_output(str(v)) print('\n---\n{}\n---'.format(v)) # Generator expression source changed in 3.8 to include parentheses, see: @@ -87,7 +87,7 @@ def test_exotic_types(): def test_newline(): v = debug.format( foobar(1, 2, 3)) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) # print(s) assert ( 'tests/test_expr_render.py: test_newline\n' @@ -100,7 +100,7 @@ def test_trailing_bracket(): v = debug.format( foobar(1, 2, 3) ) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) # print(s) assert ( 'tests/test_expr_render.py: test_trailing_bracket\n' @@ -115,7 +115,7 @@ def test_multiline(): 2, 3) ) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) # print(s) assert ( 'tests/test_expr_render.py: test_multiline\n' @@ -128,7 +128,7 @@ def test_multiline_trailing_bracket(): v = debug.format( foobar(1, 2, 3 )) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) # print(s) assert ( 'tests/test_expr_render.py: test_multiline_trailing_bracket\n' @@ -144,7 +144,7 @@ def test_kwargs(): a=6, b=7 ) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert ( 'tests/test_expr_render.py: test_kwargs\n' ' foobar(1, 2, 3): 6 (int)\n' @@ -162,7 +162,7 @@ def test_kwargs_multiline(): a=6, b=7 ) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert ( 'tests/test_expr_render.py: test_kwargs_multiline\n' ' foobar(1, 2, 3): 6 (int)\n' @@ -178,7 +178,7 @@ def test_multiple_trailing_lines(): 1, 2, 3 ), ) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert ( 'tests/test_expr_render.py: test_multiple_trailing_lines\n foobar( 1, 2, 3 ): 6 (int)' ) == s @@ -201,7 +201,7 @@ def func(): v = func() # check only the original code is included in the warning - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: func\n' ' abs( abs( abs( abs( -1 ) ) ) ): 1 (int)' @@ -227,7 +227,7 @@ def func(): v = func() # check only the original code is included in the warning - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: func\n' ' abs( abs( abs( abs( abs( -1 ) ) ) ) ): 1 (int)' @@ -254,7 +254,7 @@ def func(): ) v = func() - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: func\n' ' abs( abs( abs( abs( abs( -1 ) ) ) ) ): 1 (int)' @@ -272,7 +272,7 @@ async def bar(): loop = asyncio.new_event_loop() v = loop.run_until_complete(bar()) loop.close() - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert ( 'tests/test_expr_render.py: bar\n' ' await foo(): 1 (int)' @@ -284,7 +284,7 @@ def test_other_debug_arg(): v = debug.format([1, 2]) # check only the original code is included in the warning - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: test_other_debug_arg\n' ' [1, 2] (list) len=2' @@ -297,7 +297,7 @@ def test_other_debug_arg_not_literal(): y = 2 v = debug.format([x, y]) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: test_other_debug_arg_not_literal\n' ' [x, y]: [1, 2] (list) len=2' @@ -310,7 +310,7 @@ def test_executing_failure(): y = 2 # executing fails inside a pytest assert ast the AST is modified - assert re.sub(r':\d{2,}', ':', str(debug.format([x, y]))) == ( + assert normalise_output(str(debug.format([x, y]))) == ( 'tests/test_expr_render.py: test_executing_failure ' '(executing failed to find the calling node)\n' ' [1, 2] (list) len=2' @@ -326,7 +326,7 @@ def test_format_inside_error(): except RuntimeError as e: v = str(e) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_expr_render.py: test_format_inside_error\n' ' [x, y]: [1, 2] (list) len=2' diff --git a/tests/test_main.py b/tests/test_main.py index 9b51b72..334557b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -8,6 +8,7 @@ from devtools import Debug, debug from devtools.ansi import strip_ansi +from tests.utils import normalise_output pytestmark = pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') @@ -18,7 +19,7 @@ def test_print(capsys): result = debug(a, b) stdout, stderr = capsys.readouterr() print(stdout) - assert re.sub(r':\d{2,}', ':', stdout) == ( + assert normalise_output(stdout) == ( 'tests/test_main.py: test_print\n' ' a: 1 (int)\n' ' b: 2 (int)\n' @@ -33,7 +34,7 @@ def test_print_kwargs(capsys): result = debug(a, b, foo=[1, 2, 3]) stdout, stderr = capsys.readouterr() print(stdout) - assert re.sub(r':\d{2,}', ':', stdout) == ( + assert normalise_output(stdout) == ( 'tests/test_main.py: test_print_kwargs\n' ' a: 1 (int)\n' ' b: 2 (int)\n' @@ -49,7 +50,7 @@ def test_print_generator(capsys): result = debug(gen) stdout, stderr = capsys.readouterr() print(stdout) - assert re.sub(r':\d{2,}', ':', stdout) == ( + assert normalise_output(stdout) == ( 'tests/test_main.py: test_print_generator\n' ' gen: (\n' ' 1,\n' @@ -66,7 +67,7 @@ def test_format(): a = b'i might bite' b = "hello this is a test" v = debug.format(a, b) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) print(s) assert s == ( "tests/test_main.py: test_format\n" @@ -119,7 +120,7 @@ def test_small_call_frame(): 2, 3, ) - assert re.sub(r':\d{2,}', ':', str(v)) == ( + assert normalise_output(str(v)) == ( 'tests/test_main.py: test_small_call_frame\n' ' 1 (int)\n' ' 2 (int)\n' @@ -135,7 +136,7 @@ def test_small_call_frame_warning(): 3, ) print('\n---\n{}\n---'.format(v)) - assert re.sub(r':\d{2,}', ':', str(v)) == ( + assert normalise_output(str(v)) == ( 'tests/test_main.py: test_small_call_frame_warning\n' ' 1 (int)\n' ' 2 (int)\n' @@ -147,7 +148,7 @@ def test_small_call_frame_warning(): def test_kwargs(): a = 'variable' v = debug.format(first=a, second='literal') - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) print(s) assert s == ( "tests/test_main.py: test_kwargs\n" @@ -160,7 +161,7 @@ def test_kwargs_orderless(): # for python3.5 a = 'variable' v = debug.format(first=a, second='literal') - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert set(s.split('\n')) == { "tests/test_main.py: test_kwargs_orderless", " first: 'variable' (str) len=8 variable=a", @@ -170,14 +171,14 @@ def test_kwargs_orderless(): def test_simple_vars(): v = debug.format('test', 1, 2) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( "tests/test_main.py: test_simple_vars\n" " 'test' (str) len=4\n" " 1 (int)\n" " 2 (int)" ) - r = re.sub(r':\d{2,}', ':', repr(v)) + r = normalise_output(repr(v)) assert r == ( " test_simple_vars arguments: 'test' (str) len=4 1 (int) 2 (int)>" ) @@ -239,7 +240,7 @@ def test_exec(capsys): def test_colours(): v = debug.format(range(6)) - s = re.sub(r':\d{2,}', ':', v.str(True)) + s = normalise_output(v.str(True)) assert s.startswith('\x1b[35mtests'), repr(s) s2 = strip_ansi(s) assert s2 == v.str(), repr(s2) @@ -249,7 +250,7 @@ def test_colours_warnings(mocker): mocked_getframe = mocker.patch('sys._getframe') mocked_getframe.side_effect = ValueError() v = debug.format('x') - s = re.sub(r':\d{2,}', ':', v.str(True)) + s = normalise_output(v.str(True)) assert s.startswith('\x1b[35m'), repr(s) s2 = strip_ansi(s) assert s2 == v.str(), repr(s2) @@ -273,7 +274,7 @@ def test_breakpoint(mocker): def test_starred_kwargs(): v = {'foo': 1, 'bar': 2} v = debug.format(**v) - s = re.sub(r':\d{2,}', ':', v.str()) + s = normalise_output(v.str()) assert set(s.split('\n')) == { 'tests/test_main.py: test_starred_kwargs', ' foo: 1 (int)', @@ -289,11 +290,10 @@ def __getattr__(self, item): b = BadPretty() v = debug.format(b) - s = re.sub(r':\d{2,}', ':', str(v)) - s = re.sub(r'0x[0-9a-f]+', '0x000', s) + s = normalise_output(str(v)) assert s == ( "tests/test_main.py: test_pretty_error\n" - " b: .BadPretty object at 0x000> (BadPretty)\n" + " b: .BadPretty object at 0x> (BadPretty)\n" " !!! error pretty printing value: RuntimeError('this is an error')" ) @@ -302,7 +302,7 @@ def test_multiple_debugs(): debug.format([i * 2 for i in range(2)]) debug.format([i * 2 for i in range(2)]) v = debug.format([i * 2 for i in range(2)]) - s = re.sub(r':\d{2,}', ':', str(v)) + s = normalise_output(str(v)) assert s == ( 'tests/test_main.py: test_multiple_debugs\n' ' [i * 2 for i in range(2)]: [0, 2] (list) len=2' diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..d254c63 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,8 @@ +import re + + +def normalise_output(s): + s = re.sub(r':\d{2,}', ':', s) + s = re.sub(r'(at 0x)\w+', r'\1', s) + s = s.replace('\\', '/') + return s From cad01d9e93c2403995907cecd0b8c9152c918498 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:24:24 +0200 Subject: [PATCH 03/13] Remove xfails for windows --- tests/test_expr_render.py | 13 ------------- tests/test_main.py | 2 -- 2 files changed, 15 deletions(-) diff --git a/tests/test_expr_render.py b/tests/test_expr_render.py index 10400bb..91efbba 100644 --- a/tests/test_expr_render.py +++ b/tests/test_expr_render.py @@ -12,7 +12,6 @@ def foobar(a, b, c): return a + b + c -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_simple(): a = [1, 2, 3] v = debug.format(len(a)) @@ -24,7 +23,6 @@ def test_simple(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_subscription(): a = {1: 2} v = debug.format(a[1]) @@ -35,7 +33,6 @@ def test_subscription(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_exotic_types(): aa = [1, 2, 3] v = debug.format( @@ -83,7 +80,6 @@ def test_exotic_types(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_newline(): v = debug.format( foobar(1, 2, 3)) @@ -95,7 +91,6 @@ def test_newline(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_trailing_bracket(): v = debug.format( foobar(1, 2, 3) @@ -108,7 +103,6 @@ def test_trailing_bracket(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_multiline(): v = debug.format( foobar(1, @@ -123,7 +117,6 @@ def test_multiline(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_multiline_trailing_bracket(): v = debug.format( foobar(1, 2, 3 @@ -136,7 +129,6 @@ def test_multiline_trailing_bracket(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') @pytest.mark.skipif(sys.version_info < (3, 6), reason='kwarg order is not guaranteed for 3.5') def test_kwargs(): v = debug.format( @@ -153,7 +145,6 @@ def test_kwargs(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') @pytest.mark.skipif(sys.version_info < (3, 6), reason='kwarg order is not guaranteed for 3.5') def test_kwargs_multiline(): v = debug.format( @@ -171,7 +162,6 @@ def test_kwargs_multiline(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_multiple_trailing_lines(): v = debug.format( foobar( @@ -184,7 +174,6 @@ def test_multiple_trailing_lines(): ) == s -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_very_nested_last_statement(): def func(): return debug.format( @@ -208,7 +197,6 @@ def func(): ) -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_syntax_warning(): def func(): return debug.format( @@ -261,7 +249,6 @@ def func(): ) -@pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') def test_await(): async def foo(): return 1 diff --git a/tests/test_main.py b/tests/test_main.py index 334557b..89dcd96 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -10,8 +10,6 @@ from devtools.ansi import strip_ansi from tests.utils import normalise_output -pytestmark = pytest.mark.xfail(sys.platform == 'win32', reason='as yet unknown windows problem') - def test_print(capsys): a = 1 From 09682007e5b2d1ebdf2517f9f2a0b9d09e0c7d71 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:32:14 +0200 Subject: [PATCH 04/13] Fix test_os_environ for windows --- tests/test_prettier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_prettier.py b/tests/test_prettier.py index 88b5ec3..cdabcd6 100644 --- a/tests/test_prettier.py +++ b/tests/test_prettier.py @@ -354,7 +354,8 @@ def test_cimultidict(): def test_os_environ(): v = pformat(os.environ) assert v.startswith('<_Environ({') - assert " 'HOME': '" in v + for key in os.environ: + assert f" '{key}': " in v class Foo: From d65fab6043b3546b50a4e352f4e9b13932f37f99 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:32:46 +0200 Subject: [PATCH 05/13] Remove unused re import --- tests/test_expr_render.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_expr_render.py b/tests/test_expr_render.py index 91efbba..dc1d7ea 100644 --- a/tests/test_expr_render.py +++ b/tests/test_expr_render.py @@ -1,5 +1,4 @@ import asyncio -import re import sys import pytest From 0cfe20ea6162add596deca861c9904bd8571f372 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:49:13 +0200 Subject: [PATCH 06/13] Handle test_print_subprocess and test_odd_path in windows --- tests/test_main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 89dcd96..8328c24 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -74,6 +74,10 @@ def test_format(): ) +@pytest.mark.xfail( + sys.platform == "win32", + reason="Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python", +) def test_print_subprocess(tmpdir): f = tmpdir.join('test.py') f.write("""\ @@ -108,7 +112,12 @@ def test_odd_path(mocker): mocked_relative_to = mocker.patch('pathlib.Path.relative_to') mocked_relative_to.side_effect = ValueError() v = debug.format('test') - assert re.search(r"/.*?/test_main.py:\d{2,} test_odd_path\n 'test' \(str\) len=4", str(v)), v + if sys.platform == "win32": + pattern = r"\w:\\.*?\\" + else: + pattern = r"/.*?/" + pattern += r"test_main.py:\d{2,} test_odd_path\n 'test' \(str\) len=4" + assert re.search(pattern, str(v)), v def test_small_call_frame(): From f3f2af4ea49c0d7947d840eda68c93740cf67c16 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 3 Sep 2021 22:51:03 +0200 Subject: [PATCH 07/13] normalise_output in test_colours --- tests/test_main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 8328c24..67ab318 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -247,10 +247,10 @@ def test_exec(capsys): def test_colours(): v = debug.format(range(6)) - s = normalise_output(v.str(True)) + s = v.str(True) assert s.startswith('\x1b[35mtests'), repr(s) - s2 = strip_ansi(s) - assert s2 == v.str(), repr(s2) + s2 = normalise_output(strip_ansi(s)) + assert s2 == normalise_output(v.str()), repr(s2) def test_colours_warnings(mocker): From 20ef6927740859f03b97997da2fe2ad9fbd6ca22 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Sun, 5 Sep 2021 16:23:04 +0200 Subject: [PATCH 08/13] Relative imports of tests.utils Co-authored-by: Samuel Colvin --- tests/test_expr_render.py | 3 ++- tests/test_main.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_expr_render.py b/tests/test_expr_render.py index dc1d7ea..9ff5fa6 100644 --- a/tests/test_expr_render.py +++ b/tests/test_expr_render.py @@ -4,7 +4,8 @@ import pytest from devtools import Debug, debug -from tests.utils import normalise_output + +from .utils import normalise_output def foobar(a, b, c): diff --git a/tests/test_main.py b/tests/test_main.py index 67ab318..06153b2 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -8,7 +8,8 @@ from devtools import Debug, debug from devtools.ansi import strip_ansi -from tests.utils import normalise_output + +from .utils import normalise_output def test_print(capsys): From 90d40dd40a36dee657ed311aa08e69462d8e4f49 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Sun, 5 Sep 2021 16:28:09 +0200 Subject: [PATCH 09/13] defer pathlib import --- devtools/debug.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devtools/debug.py b/devtools/debug.py index c9a8aa5..1954bf5 100644 --- a/devtools/debug.py +++ b/devtools/debug.py @@ -1,6 +1,5 @@ import os import sys -from pathlib import Path from .ansi import sformat from .prettier import PrettyFormat @@ -144,6 +143,8 @@ def _process(self, args, kwargs) -> DebugOutput: function = call_frame.f_code.co_name + from pathlib import Path + path = Path(call_frame.f_code.co_filename) if path.is_absolute(): # make the path relative From 5c65634592d481e3d413d5e524b758172a510edb Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sun, 5 Sep 2021 17:48:00 +0100 Subject: [PATCH 10/13] set CI to work on windows --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75b669f..7d5c4cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,9 @@ jobs: - run: pip freeze - name: test with extras - run: | - make test - coverage xml + run: make test + + - run: coverage xml - uses: codecov/codecov-action@v2.0.3 with: @@ -71,9 +71,9 @@ jobs: run: pip uninstall -y multidict numpy pydantic asyncpg - name: test without extras - run: | - make test - coverage xml + run: make test + + - run: coverage xml - uses: codecov/codecov-action@v2.0.3 with: From 5fa4c22fb12920638644eb6d9ceccc7fafb1657b Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sun, 5 Sep 2021 17:53:48 +0100 Subject: [PATCH 11/13] fix test_use_highlight_auto_win --- tests/test_utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 9c455b0..b9cca04 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -43,8 +43,4 @@ def test_use_highlight_auto_win(monkeypatch): monkeypatch.delenv('TEST_DONT_USE_HIGHLIGHT', raising=False) monkeypatch.setattr(devtools.utils, 'isatty', lambda _=None: True) - monkeypatch.setattr(devtools.utils, 'color_active', False) assert use_highlight() is False - - monkeypatch.setattr(devtools.utils, 'color_active', True) - assert use_highlight() is True From 57b1871f8c41ed5ad0fd758fd6e6b5b54eca2247 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sun, 5 Sep 2021 17:55:23 +0100 Subject: [PATCH 12/13] fix test_use_highlight_auto_win, take 2 --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index b9cca04..d7c5681 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -43,4 +43,4 @@ def test_use_highlight_auto_win(monkeypatch): monkeypatch.delenv('TEST_DONT_USE_HIGHLIGHT', raising=False) monkeypatch.setattr(devtools.utils, 'isatty', lambda _=None: True) - assert use_highlight() is False + assert use_highlight() is True From 453eabd15584f2b8941e4fc14a401e5a9b540782 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sun, 5 Sep 2021 18:19:39 +0100 Subject: [PATCH 13/13] xfail test_starred_kwargs on windows --- tests/test_main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 06153b2..667a79a 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -76,8 +76,8 @@ def test_format(): @pytest.mark.xfail( - sys.platform == "win32", - reason="Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python", + sys.platform == 'win32', + reason='Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python', ) def test_print_subprocess(tmpdir): f = tmpdir.join('test.py') @@ -279,6 +279,10 @@ def test_breakpoint(mocker): assert mocked_set_trace.called +@pytest.mark.xfail( + sys.platform == 'win32' and sys.version_info >= (3, 9), + reason='see https://github.com/alexmojaki/executing/issues/27', +) def test_starred_kwargs(): v = {'foo': 1, 'bar': 2} v = debug.format(**v)