kiwi-el8/test/unit/utils/temporary_test.py
Marcus Schäfer 9c9250ebc4
Support nose and xunit style tests
The modifications in this commit allows the unit tests
to run on both, pytest 6.x (nose test layout) and the new
pytest 7.x (xunit test layout). This Fixes #2072 in a
much nicer way. Thanks much to @smarlowucf
2022-02-26 20:26:18 +01:00

26 lines
707 B
Python

from mock import patch
from kiwi.utils.temporary import Temporary
class TestTemporary:
def setup(self):
self.temporary = Temporary()
def setup_method(self, cls):
self.setup()
@patch('kiwi.utils.temporary.NamedTemporaryFile')
def test_new_file(self, mock_NamedTemporaryFile):
self.temporary.new_file()
mock_NamedTemporaryFile.assert_called_once_with(
dir='/var/tmp', prefix='kiwi_'
)
@patch('kiwi.utils.temporary.TemporaryDirectory')
def test_new_dir(self, mock_TemporaryDirectory):
self.temporary.new_dir()
mock_TemporaryDirectory.assert_called_once_with(
dir='/var/tmp', prefix='kiwi_'
)