code: def test_writing(self):
      # First read in stuff.
      mnist_builder = mnist.MNIST(data_dir=_DATA_DIR)
  
      info = dataset_info.DatasetInfo(
          builder=mnist_builder, features=mnist_builder.info.features
      )
      info.read_from_directory(_INFO_DIR)
  
      # Read the json file into a string.
      with tf.io.gfile.GFile(
          dataset_info.dataset_info_path(_INFO_DIR)
      ) as f:
          existing_json = json.load(f)
  
      # Now write to a temp directory.
      with testing.tmp_dir(self.get_temp_dir()) as tmp_dir:
          info.write_to_directory(tmp_dir)
  
          # Read the newly written json file into a string.
          with tf.io.gfile.GFile(
              dataset_info.dataset_info_path(tmp_dir)
          ) as f:
              new_json = json.load(f)
  
          # Read the newly written LICENSE file into a string.
          with tf.io.gfile.GFile(
              dataset_info.license_path(tmp_dir)
          ) as f:
              license_ = f.read()
  
      # Assert what was read and then written and read again is the same.
      self.assertEqual(existing_json, new_json)
  
      # Assert correct license was written.
      self.assertEqual(
          existing_json["redistributionInfo"]["license"], license_
      )
  
      # Do not check the full string as it display the generated path.
      self.assertEqual(_INFO_STR % mnist_builder.data_dir, repr(info))
      self.assertIn("'test': <SplitInfo num_examples=", repr(info))
  
imports: import json
  import os
  import pathlib
  import tempfile
  import time
  from typing import Union
  import numpy
  import pytest
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import read_only_builder
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.proto import dataset_info_pb2
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.image_classification import mnist
  from tensorflow_datasets.testing.dummy_config_based_datasets.dummy_ds_1 import dummy_ds_1_dataset_builder
  from google.protobuf import text_format
label_desc: Use image node_id 8 for calling the DatasetInfoTest obj's underlying member method code with example usage: obj.test_writing() without return types