class_docstr: Dependency management API tests.
  - mock()
  - extern()
  - deny()
class_docstr_tok: ["Dependency","management","API","tests",".","-","mock","(",")","-","extern","(",")","-","deny","(",")"]
docstr: Test that an error is thrown when a mock glob is specified with allow_empty=True
  and no matching module is required during packaging.
docstr_tok: ["Test","that","an","error","is","thrown","when","a","mock","glob","is","specified","with","allow_empty=True","and","no","matching","module","is","required","during","packaging","."]
code: def test_mock_glob_allow_empty(self):
      """
      Test that an error is thrown when a mock glob is specified with allow_empty=True
      and no matching module is required during packaging.
      """
      import package_a.subpackage  # noqa: F401
  
      buffer = BytesIO()
      with self.assertRaisesRegex(
          EmptyMatchError, r"did not match any modules"
      ):
          with PackageExporter(buffer) as exporter:
              exporter.mock(include=["package_b.*"], allow_empty=False)
              exporter.save_module("package_a.subpackage")
  
imports: import importlib
  from io import BytesIO
  from sys import version_info
  from textwrap import dedent
  from unittest import skipIf
  import torch.nn
  from torch.package import EmptyMatchError, Importer, PackageExporter, PackageImporter
  from torch.package.package_exporter import PackagingError
  from torch.testing._internal.common_utils import IS_WINDOWS, run_tests
label_desc: Use image node_id 8 for calling the TestDependencyAPI obj's underlying member method code with example usage: obj.test_mock_glob_allow_empty() without return types