code: def test_creation():
      F = QQ.old_poly_ring(x).free_module(3)
      G = QQ.old_poly_ring(x).free_module(2)
      SM = F.submodule([1, 1, 1])
      Q = F / SM
      SQ = Q.submodule([1, 0, 0])
  
      matrix = [[1, 0], [0, 1], [-1, -1]]
      h = homomorphism(F, G, matrix)
      h2 = homomorphism(Q, G, matrix)
      assert h.quotient_domain(SM) == h2
      raises(
          ValueError, lambda: h.quotient_domain(F.submodule([1, 0, 0]))
      )
      assert h2.restrict_domain(SQ) == homomorphism(SQ, G, matrix)
      raises(ValueError, lambda: h.restrict_domain(G))
      raises(
          ValueError, lambda: h.restrict_codomain(G.submodule([1, 0]))
      )
      raises(ValueError, lambda: h.quotient_codomain(F))
  
      im = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
      for M in [F, SM, Q, SQ]:
          assert M.identity_hom() == homomorphism(M, M, im)
      assert SM.inclusion_hom() == homomorphism(SM, F, im)
      assert SQ.inclusion_hom() == homomorphism(SQ, Q, im)
      assert Q.quotient_hom() == homomorphism(F, Q, im)
      assert SQ.quotient_hom() == homomorphism(SQ.base, SQ, im)
  
      class conv:
          def convert(x, y=None):
              return x
  
      class dummy:
          container = conv()
  
          def submodule(*args):
              return None
  
      raises(TypeError, lambda: homomorphism(dummy(), G, matrix))
      raises(TypeError, lambda: homomorphism(F, dummy(), matrix))
      raises(
          ValueError,
          lambda: homomorphism(
              QQ.old_poly_ring(x, y).free_module(3), G, matrix
          ),
      )
      raises(ValueError, lambda: homomorphism(F, G, [0, 0]))
  
file_path: sympy/sympy/polys/agca/tests/test_homomorphisms.py
imports: from sympy.core.singleton import S
  from sympy.polys.domains.rationalfield import QQ
  from sympy.abc import x, y
  from sympy.polys.agca import homomorphism
  from sympy.testing.pytest import raises
label_desc: Use image node_id 3 for calling a global function with example usage: test_creation() and returns: x, None