I was trying to implement unit tests for a YAML configuration file class.
Is it something to be avoided? Is it sub-optimal in terms of resource usage or maintainability?
Below is a sample test:
import pytest from unittest.mock import patch, mock_open from configurationfile import ConfigurationFile @pytest.fixture def mock_configuration(): initial_mock_data = """--- s3_bucket_name: s3_bucket_name_value s3_object_name: s3_object_name_value""" with patch('builtins.open', mock_open(read_data=initial_mock_data)): return ConfigurationFile() def test_read_yaml_file(mock_configuration): assert mock_configuration.configuration['s3_bucket_name'] == 's3_bucket_name_value' assert mock_configuration.configuration['s3_object_name'] == 's3_object_name_value'