def assert_new_op_prefixes(test, expected_prefix, assert_some_new_ops=True):
  """Asserts the namescope of tf ops created within the context manager."""
  ops_before = [n.name for n in tf.get_default_graph().as_graph_def().node]
  yield
  ops_after = [n.name for n in tf.get_default_graph().as_graph_def().node]
  new_ops = set(ops_after) - set(ops_before)
  prefix_length = len(expected_prefix)
  if assert_some_new_ops:
    test.assertNotEqual(0, len(new_ops))
  for op_name in new_ops:
    test.assertEqual(expected_prefix, op_name[:prefix_length])
Asserts the namescope of tf ops created within the context manager.
graph_nets/tests_tf2/test_utils.py