tests: use tmp_path fixture in test_curl_source.py
Tiny tweak to remove some boilerplate related to tmpfile handling. The pytest `tmp_path` fixture gives us the tmpdir without having to worry about cleanup etc (and in a slightly more concise way).
This commit is contained in:
parent
fb701d6db5
commit
79d788ac23
1 changed files with 5 additions and 9 deletions
|
|
@ -2,32 +2,28 @@
|
|||
|
||||
import contextlib
|
||||
import os
|
||||
import pathlib
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
SOURCES_NAME = "org.osbuild.curl"
|
||||
|
||||
|
||||
def test_curl_source_not_exists(sources_service):
|
||||
tmpdir = tempfile.TemporaryDirectory()
|
||||
sources_service.cache = tmpdir.name
|
||||
def test_curl_source_not_exists(tmp_path, sources_service):
|
||||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
}
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
sources_service.cache = tmp_path
|
||||
assert not sources_service.exists(checksum, desc)
|
||||
|
||||
|
||||
def test_curl_source_exists(sources_service):
|
||||
tmpdir = tempfile.TemporaryDirectory()
|
||||
sources_service.cache = tmpdir.name
|
||||
def test_curl_source_exists(tmp_path, sources_service):
|
||||
desc = {
|
||||
"url": "http://localhost:80/a",
|
||||
}
|
||||
checksum = "sha256:1111111111111111111111111111111111111111111111111111111111111111"
|
||||
pathlib.Path(os.path.join(tmpdir.name, checksum)).touch()
|
||||
sources_service.cache = tmp_path
|
||||
(sources_service.cache / checksum).touch()
|
||||
assert sources_service.exists(checksum, desc)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue