|
| 1 | +from pathlib import Path |
| 2 | +from subprocess import run |
| 3 | + |
| 4 | + |
| 5 | +def test_not_safe_for_parallel_read(rootdir: Path, tmp_path: Path): |
| 6 | + """Ablog is NOT safe for parallel read. In such case, it doesn't collect any posts.""" |
| 7 | + # https://github.com/sunpy/ablog/issues/297 |
| 8 | + # Very ugly hack to change the parallel_read_safe value to True |
| 9 | + good_read_safe = '"parallel_read_safe": False' |
| 10 | + bad_read_safe = '"parallel_read_safe": True' |
| 11 | + init_py_path = Path(__file__).parent.parent / "__init__.py" |
| 12 | + assert good_read_safe in init_py_path.read_text(encoding="utf-8") |
| 13 | + bad_init_py = init_py_path.read_text().replace(good_read_safe, bad_read_safe) |
| 14 | + init_py_path.write_text(bad_init_py, encoding="utf-8") |
| 15 | + |
| 16 | + # liborjelinek: I wasn't able to demonstrate the issue with the `parallel` argument to the `sphinx` fixture |
| 17 | + # @pytest.mark.sphinx("html", testroot="parallel", parallel=2) |
| 18 | + # therefore running sphinx-build externally |
| 19 | + indir = rootdir / "test-parallel" |
| 20 | + run(["sphinx-build", "-b", "html", indir.as_posix(), tmp_path.as_posix(), "-j", "auto"], check=True) |
| 21 | + |
| 22 | + # And posts are not collected by Ablog... |
| 23 | + html = (tmp_path / "postlist.html").read_text(encoding="utf-8") |
| 24 | + assert "post 1" not in html |
| 25 | + assert "post 2" not in html |
| 26 | + assert "post 3" not in html |
| 27 | + assert "post 4" not in html |
0 commit comments