def test_read_from_from_file_fails_if_unknown_extension(self): with self.assertRaisesRegexp(ValueError, "txt"): utils.read_from_file("test.txt")
def test_read_from_yaml_file(self, open_mock): mock.mock_open(open_mock, read_data='key: value') self.assertEqual( {"key": "value"}, utils.read_from_file("test.YAML") )
def test_read_from_from_file_if_none(self): self.assertIsNone(utils.read_from_file(None))
def test_read_from_json_file(self, open_mock): mock.mock_open(open_mock, read_data='{"key": "value"}') self.assertEqual( {"key": "value"}, utils.read_from_file("test.json") )