docstr: If dst is not opened when attempting to write data, runtime error should be raised
docstr_tok: ["If","dst","is","not","opened","when","attempting","to","write","data",",","runtime","error","should","be","raised"]
code: def test_unopened_error(self):
      """If dst is not opened when attempting to write data, runtime error should be raised"""
      path = self.get_dst("test.mp4")
      s = StreamWriter(path, format="mp4")
      s.set_metadata(
          metadata={"artist": "torchaudio", "title": self.id()}
      )
      s.add_audio_stream(sample_rate=16000, num_channels=2)
      s.add_video_stream(frame_rate=30, width=16, height=16)
  
      dummy = torch.zeros((3, 2))
      with self.assertRaises(RuntimeError):
          s.write_audio_chunk(0, dummy)
  
      dummy = torch.zeros((3, 3, 16, 16))
      with self.assertRaises(RuntimeError):
          s.write_video_chunk(1, dummy)
  
imports: import io
  import math
  import torch
  import torchaudio
  from parameterized import parameterized, parameterized_class
  from torchaudio.io import CodecConfig, StreamReader, StreamWriter
  from torchaudio_unittest.common_utils import get_asset_path, get_sinusoid, nested_params, rgb_to_yuv_ccir, skipIfNoFFmpeg, skipIfNoModule, TempDirMixin, TorchaudioTestCase
  from .common import lt42
label_desc: Use image node_id 4 for calling the StreamWriterInterfaceTest obj's underlying member method code with example usage: obj.test_unopened_error() without return types