Skip to content

Fix du test #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import pathlib
import subprocess
import sys
import tempfile

import numpy as np
import pytest
Expand Down Expand Up @@ -231,16 +234,19 @@ def test_examples(self, chunk_size, size, start, stop):

@pytest.mark.skipif(sys.platform != "linux", reason="Only valid on Linux")
@pytest.mark.parametrize(
("path", "expected"),
"path",
[
# NOTE: this data is generated using du -sb on a Linux system.
# It works in CI on Linux, but it'll probably break at some point.
# It's also necessary to update these numbers each time a new data
# file gets added
("tests/data", 4983044),
("tests/data/vcf", 4970907),
("tests/data/vcf/sample.vcf.gz", 1089),
"tests/data",
"tests/data/vcf",
"tests/data/vcf/sample.vcf.gz",
],
)
def test_du(path, expected):
assert core.du(path) == expected
def test_du(path):
with tempfile.TemporaryDirectory() as tmp_dir:
subprocess.check_call(["cp", "-pR", "tests", tmp_dir])
copy_path = pathlib.Path(tmp_dir) / path
s = subprocess.check_output(
["du", "-sb", "--apparent-size", str(copy_path)]
).decode()
value = int(s.split()[0])
assert core.du(path) == value
Loading