Skip to content

Commit

Permalink
test: skip if input file doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
purarue committed Nov 5, 2023
1 parent 5e13bde commit 23364a9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_split_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ def in_golang_dir() -> Generator[None, None, None]:
os.chdir(current_dir)


@pytest.mark.skipif(
not Path(activity_html_file).is_file(),
reason=f"activity_html_file at '{activity_html_file}' does not exist",
)
@pytest.mark.skipif(
"TEST_GOLANG_SPLIT" not in os.environ,
reason="TEST_GOLANG_SPLIT not set, skipping test",
)
def test_split_html(in_golang_dir: None) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
assert Path(temp_dir).is_dir()
subprocess.run(
[
"go",
Expand All @@ -47,12 +52,11 @@ def test_split_html(in_golang_dir: None) -> None:
check=True,
)

assert Path(temp_dir).is_dir()

from_merged = []

# parse the split files
files = sorted(Path(temp_dir).iterdir())
assert len(files) > 1
assert len(files) > 1, f"found no split files in '{temp_dir}'"
for file in files:
assert file.is_file()
assert file.stat().st_size > 0
Expand All @@ -62,6 +66,7 @@ def test_split_html(in_golang_dir: None) -> None:
raise x
from_merged.append(x)

# parse the original file
from_original = [
a
for a in _parse_html_activity(Path(activity_html_file))
Expand All @@ -73,5 +78,6 @@ def test_split_html(in_golang_dir: None) -> None:
from_merged.sort(key=lambda x: x.time)
from_original.sort(key=lambda x: x.time)

# checks that every parsed element is the same
for a, b in zip(from_merged, from_original):
assert a == b

0 comments on commit 23364a9

Please sign in to comment.