class_docstr: Dependency management API tests.
  - mock()
  - extern()
  - deny()
class_docstr_tok: ["Dependency","management","API","tests",".","-","mock","(",")","-","extern","(",")","-","deny","(",")"]
docstr: Test marking packages as "deny" during export.
docstr_tok: ["Test","marking","packages","as","``","deny","''","during","export","."]
code: def test_deny(self):
      """
      Test marking packages as "deny" during export.
      """
      buffer = BytesIO()
  
      with self.assertRaisesRegex(PackagingError, "denied"):
          with PackageExporter(buffer) as exporter:
              exporter.deny(["package_a.subpackage", "module_a"])
              exporter.save_source_string(
                  "foo", "import 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 4 for calling the TestDependencyAPI obj's underlying member method code with example usage: obj.test_deny() without return types