code: def test_union_name_preservation(
      self,
      first_list,
      second_list,
      first_name,
      second_name,
      expected_name,
      sort,
  ):
      first = Index(first_list, name=first_name)
      second = Index(second_list, name=second_name)
      union = first.union(second, sort=sort)
  
      vals = set(first_list).union(second_list)
  
      if sort is None and len(first_list) > 0 and len(second_list) > 0:
          expected = Index(sorted(vals), name=expected_name)
          tm.assert_index_equal(union, expected)
      else:
          expected = Index(vals, name=expected_name)
          tm.assert_index_equal(
              union.sort_values(), expected.sort_values()
          )
  
imports: from datetime import datetime
  import numpy
  import pytest
  import pandas
  from pandas import Index, Series
  import pandas._testing
  from pandas.core.algorithms import safe_sort
label_desc: Use image node_id 17 for calling the TestIndexSetOps obj's underlying member method code with example usage: obj.test_union_name_preservation(first_list, second_list, first_name, second_name, expected_name, sort) without return types