Stop doctests polluting current dir with temporary files
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start by reading the run-doctests tool and the doctests that create temporary netCDF files in the current directory; the issue does not name specific files or tests. Compare the proposed temporary-working-directory approach with a shared temporary-directory utility, keeping local-code imports and cleanup behavior in mind. Done means doctests no longer leave temporary netCDF files in the project directory without disrupting their execution.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
At present, when you run any doctests temporary netCDF files are created in the current directory.
This is slightly tiresome, and could be avoided by dumping files to a temporary directory, like pytest does.
Unfortunately, adding specific code to do that in every module / docs-sourcefile could also be tiresome and intrusive.
in run-doctests
Possibly, a way to control this could be added to the run_doctests tool ?
- e.g., run by default in a temporary cwd -
- but that could affect doctest execution, and make some things difficult (e.g. importing local code) ??
using tempfile
instead of e.g. data.to_nc4('tmp.nc'),
import pathlib
import testfile
tempdir = pathlib.Path(testfile.TemporaryDirectory())
# ...
path = tempdir / "tmp.nc"
to_nc4(data, path)
result = from_nc4(path)
with a test utility
Or.. A utility to create a temp directory that will be consistently destroyed afterwards might be useful
(as opposed to tempdir which does not arrange for destruction).
# in <testutils.py>
import pathlib
class TempDir(pathlib.Path):
def __init__(self):
# self.context is deleted when self is deleted --> destroys directory
self.context = tempfile.TemporaryDirectory()
self.path_str = self.context.__enter__()
self.path = pathlib.Path(self.dirpath_str)
# a single common per-import object
tempdir = TempDir()
# ...
# in docstrings / docs
# Usage is generally shorter, and directory is removed on program exit
>>> from testutils import tempdir
...
>>> filepath = tempdir.path / "tmp.nc"
>>> to_nc4(data, filepath)
>>> result = from_nc4(filepath)
- Ngôn ngữ chính
- Python
- Star
- 16
- Fork
- 6
- Merge trung bình
- 2 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SciTools/ncdata
-
Link Checker ReportĐang mởautomated issue report
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Fix homepage linkĐang mởscitools
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
Fix license controlĐang mởscitools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Release fix for Iris 3.17Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
Tất cả issue của SciTools/ncdata
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
UKGovernmentBEIS/inspect_ai#6733 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ProyectoRespira/respira-webapp#334 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security-alert
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
spectrayan/carefold#391 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Jakeschincariol/instagram-agent-skill#83 ·
Maintainer thường phản hồi trong vòng 10 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 64/100