code: def test_sign_stdin(self):
      def sign_stdin(nb):
          env = os.environ.copy()
          env["JUPYTER_DATA_DIR"] = self.data_dir
          p = Popen(
              [
                  sys.executable,
                  "-m",
                  "nbformat.sign",
                  "--log-level=0",
              ],  # noqa
              stdin=PIPE,
              stdout=PIPE,
              env=env,
          )
          assert p.stdin is not None
          write(nb, codecs.getwriter("utf8")(p.stdin))
          p.stdin.close()
          p.wait()
          self.assertEqual(p.returncode, 0)
          assert p.stdout is not None
          out = p.stdout.read().decode("utf8", "replace")
          p.stdout.close()
          return out
  
      out = sign_stdin(self.nb3)
      self.assertIn("Signing notebook: <stdin>", out)
      out = sign_stdin(self.nb3)
      self.assertIn("already signed: <stdin>", out)
  
imports: from __future__ import annotations
  import codecs
  import copy
  import os
  import shutil
  import sys
  import tempfile
  import time
  import unittest
  from subprocess import PIPE, Popen
  import testpath
  from traitlets.config import Config
  from nbformat import read, sign, write
  from .base import TestsBase
label_desc: Use image node_id 18 for calling the TestNotary obj's underlying member method code with example usage: obj.test_sign_stdin() and returns: out