allow tests/tools/test_full_sync.py::test_full_sync_test to run on 3.7 (#15570)

* allow tests/tools/test_full_sync.py::test_full_sync_test to run on 3.7

* drop dirs_exist_ok=

* more

* less
This commit is contained in:
Kyle Altendorf 2023-06-21 19:14:34 -04:00 committed by GitHub
parent ff11e3e06a
commit 03943a0e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 17 deletions

View File

@ -29,13 +29,13 @@ NUM_PEERS = 5
@contextmanager
def enable_profiler(profile: bool, name: str) -> Iterator[None]:
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required, running with: {sys.version}")
if not profile:
yield
return
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required when profiling is requested, running with: {sys.version}")
with cProfile.Profile() as pr:
yield

View File

@ -18,13 +18,13 @@ with_profile = False
@contextmanager
def enable_profiler(name: str) -> Iterator[None]:
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required, running with: {sys.version}")
if not with_profile:
yield
return
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required when profiling is requested, running with: {sys.version}")
with cProfile.Profile() as pr:
yield

View File

@ -23,13 +23,13 @@ from tools.test_constants import test_constants
@contextmanager
def enable_profiler(profile: bool, counter: int) -> Iterator[None]:
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required, running with: {sys.version}")
if not profile:
yield
return
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required when profiling is requested, running with: {sys.version}")
with cProfile.Profile() as pr:
yield

View File

@ -46,13 +46,13 @@ class ExitOnError(logging.Handler):
@contextmanager
def enable_profiler(profile: bool, counter: int) -> Iterator[None]:
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required, running with: {sys.version}")
if not profile:
yield
return
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required when profiling is requested, running with: {sys.version}")
with cProfile.Profile() as pr:
receive_start_time = time.monotonic()
yield
@ -112,9 +112,6 @@ async def run_sync_test(
node_profiler: bool,
start_at_checkpoint: Optional[str],
) -> None:
if sys.version_info < (3, 8):
raise Exception(f"Python 3.8 or higher required, running with: {sys.version}")
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
handler = logging.FileHandler("test-full-sync.log")
@ -129,9 +126,9 @@ async def run_sync_test(
logger.addHandler(check_log)
with tempfile.TemporaryDirectory() as root_dir:
root_path = Path(root_dir)
root_path = Path(root_dir, "root")
if start_at_checkpoint is not None:
shutil.copytree(Path(start_at_checkpoint) / ".", root_path, dirs_exist_ok=True)
shutil.copytree(start_at_checkpoint, root_path)
chia_init(root_path, should_check_keys=False, v1_db=(db_version == 1))
config = load_config(root_path, "config.yaml")