Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed May 22, 2024
1 parent 101939c commit 6d68858
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os

import pytest
from shutil import copyfileobj

TEST_DIR = os.path.dirname(__file__)
TEST_FILES = f"{TEST_DIR}/files"
Expand All @@ -15,14 +14,15 @@ def _patch_get_potential_energy(monkeypatch) -> None:
"""Monkeypatch the multiprocessing.cpu_count() function to always return 64."""
monkeypatch.setattr(multiprocessing, "cpu_count", lambda: 64)

def get_gzip_or_unzipped(test_file_or_dir : str) -> str:
"""

def get_gzip_or_unzipped(test_file_or_dir: str) -> str:
"""
Return the file or its unzipped version, depending on which one exists.
Running pytest in CI seems to unzip the test files prior to testing.
To get around this behavior, we return the whichever file exists,
its gzipped version or the unzipped version.
Args:
test_file_or_dir (str) : the name of the test file or directory
Returns:
Expand All @@ -31,8 +31,8 @@ def get_gzip_or_unzipped(test_file_or_dir : str) -> str:
"""
if os.path.isdir(test_file_or_dir):
return test_file_or_dir

for file_to_test in [test_file_or_dir, test_file_or_dir.split(".gz")[0], test_file_or_dir.split(".GZ")[0]]:
if os.path.isfile(file_to_test):
return file_to_test
raise FileNotFoundError(f"Cannot find {test_file_or_dir}")
raise FileNotFoundError(f"Cannot find {test_file_or_dir}")

0 comments on commit 6d68858

Please sign in to comment.