-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest_console.py
More file actions
65 lines (49 loc) · 2.14 KB
/
test_console.py
File metadata and controls
65 lines (49 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import pytest
import requests
from ydata_profiling.controller import console
from ydata_profiling.utils.paths import get_config
NASA_URL = "https://data.nasa.gov/docs/legacy/meteorite_landings/Meteorite_Landings.csv"
@pytest.fixture
def console_data(get_data_file):
try:
return get_data_file("meteorites.csv", NASA_URL)
except requests.RequestException as e:
pytest.skip(f"Skipping console tests: NASA dataset unavailable ({e})")
except Exception as e:
pytest.skip(f"Skipping console tests: cannot fetch meteorites.csv ({e})")
@pytest.mark.skipif(os.name == "nt", reason="multiprocessing+pytest broken on Windows")
def test_console_multiprocessing(console_data, test_output_dir):
report = test_output_dir / "test_samples.html"
console.main(["-s", "--pool_size", "0", str(console_data), str(report)])
assert report.exists(), "Report should exist"
def test_console_single_core(console_data, test_output_dir):
report = test_output_dir / "test_single_core.html"
console.main(["-s", "--pool_size", "1", str(console_data), str(report)])
assert report.exists(), "Report should exist"
def test_console_minimal(console_data, test_output_dir):
report = test_output_dir / "test_minimal.html"
console.main(["-s", "--minimal", str(console_data), str(report)])
assert report.exists(), "Report should exist"
def test_console_explorative(console_data, test_output_dir):
report = test_output_dir / "test_explorative.html"
console.main(
["-s", "--pool_size", "1", "--explorative", str(console_data), str(report)]
)
assert report.exists(), "Report should exist"
def test_double_config(console_data, test_output_dir):
report = test_output_dir / "test_double_config.html"
with pytest.raises(ValueError) as e:
console.main(
[
"-s",
"--config_file",
str(get_config("config_default.yaml")),
"--minimal",
str(console_data),
str(report),
]
)
assert (
str(e.value) == "Arguments `config_file` and `minimal` are mutually exclusive."
)