From 1d92f2552ab1eb726fe6a2471a594b2e90b520d1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 27 Jan 2023 16:41:16 -0500 Subject: [PATCH] Adjust other examples tests to expect `pathlib` objects --- tests/test_debugger.py | 24 +++++++++++------------- tests/test_docs_examples.py | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/tests/test_debugger.py b/tests/test_debugger.py index 0793df5..7885034 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -14,6 +14,7 @@ import itertools from os import path from typing import Optional import platform +import pathlib import sys import time @@ -24,7 +25,10 @@ from pexpect.exceptions import ( EOF, ) -from conftest import repodir, _ci_env +from conftest import ( + examples_dir, + _ci_env, +) # TODO: The next great debugger audit could be done by you! # - recurrent entry to breakpoint() from single actor *after* and an @@ -43,19 +47,13 @@ if platform.system() == 'Windows': ) -def examples_dir(): - """Return the abspath to the examples directory. - """ - return path.join(repodir(), 'examples', 'debugging/') - - def mk_cmd(ex_name: str) -> str: - """Generate a command suitable to pass to ``pexpect.spawn()``. - """ - return ' '.join( - ['python', - path.join(examples_dir(), f'{ex_name}.py')] - ) + ''' + Generate a command suitable to pass to ``pexpect.spawn()``. + + ''' + script_path: pathlib.Path = examples_dir() / 'debugging' / f'{ex_name}.py' + return ' '.join(['python', str(script_path)]) # TODO: was trying to this xfail style but some weird bug i see in CI diff --git a/tests/test_docs_examples.py b/tests/test_docs_examples.py index 4139836..31eca88 100644 --- a/tests/test_docs_examples.py +++ b/tests/test_docs_examples.py @@ -12,17 +12,17 @@ import shutil import pytest -from conftest import repodir - - -def examples_dir(): - """Return the abspath to the examples directory. - """ - return os.path.join(repodir(), 'examples') +from conftest import ( + examples_dir, +) @pytest.fixture -def run_example_in_subproc(loglevel, testdir, arb_addr): +def run_example_in_subproc( + loglevel: str, + testdir, + arb_addr: tuple[str, int], +): @contextmanager def run(script_code): @@ -32,8 +32,8 @@ def run_example_in_subproc(loglevel, testdir, arb_addr): # on windows we need to create a special __main__.py which will # be executed with ``python -m `` on windows.. shutil.copyfile( - os.path.join(examples_dir(), '__main__.py'), - os.path.join(str(testdir), '__main__.py') + examples_dir() / '__main__.py', + str(testdir / '__main__.py'), ) # drop the ``if __name__ == '__main__'`` guard onwards from