test/sources: tmpdir as fixture
Instead of creating the temporaroy directory within the unit test, provide it to the test via a test fixture.
This commit is contained in:
parent
518940cfe0
commit
92fad13dbf
1 changed files with 8 additions and 3 deletions
|
|
@ -97,9 +97,15 @@ def check_case(source, case, store, libdir):
|
|||
raise ValueError(f"invalid expectation: {expects}")
|
||||
|
||||
|
||||
@pytest.fixture(name="tmpdir")
|
||||
def tmpdir_fixture():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yield tmp
|
||||
|
||||
|
||||
@pytest.mark.skipif(not can_setup_netns(), reason="network namespace setup failed")
|
||||
@pytest.mark.parametrize("source,case", make_test_cases())
|
||||
def test_sources(source, case):
|
||||
def test_sources(source, case, tmpdir):
|
||||
index = osbuild.meta.Index(os.curdir)
|
||||
sources = os.path.join(test.TestBase.locate_test_data(), "sources")
|
||||
|
||||
|
|
@ -113,8 +119,7 @@ def test_sources(source, case):
|
|||
|
||||
src = osbuild.sources.Source(info, items, options)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir, \
|
||||
osbuild.objectstore.ObjectStore(tmpdir) as store, \
|
||||
with osbuild.objectstore.ObjectStore(tmpdir) as store, \
|
||||
fileServer(test.TestBase.locate_test_data()):
|
||||
check_case(src, case_options, store, index.path)
|
||||
check_case(src, case_options, store, index.path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue