code: def test_as_filename_raises_error_when_field_is_not_filename(
      self,
  ) -> None:
      with pytest.raises(
          AssetCardError,
          match=r"^The value of the field 'field6' of the asset card 'test-card' must be a filename, but is 'invalid/filename' instead\.$",
      ):
          self.card.field("field6").as_filename()
  
imports: from os import PathLike
  from pathlib import Path
  import pytest
  from fairseq2.assets import AssetCard, AssetCardError, AssetCardFieldNotFoundError
label_desc: Use image node_id 21 for calling the TestAssetCard obj's underlying member method code with example usage: obj.test_as_filename_raises_error_when_field_is_not_filename() without return types