1

When running unittest, I receive a "not all arguments converted during string formatting." When running the code directly, everything works fine; it's only running Unittest that's a problem. When I run the same exact command map.add_node('a','b','c','d') directly there is no problem

Main program:

    def add_node(self, *args):
      main_node = args[0]
      connected_nodes = args[1:]
      if main_node in self.graph_dict:
        main_node = str(main_node) #getting desperate here
        print('%s in graph already. Updating...\n' % main_node) #** problem is here
      else:
        print('%s added.\n' % main_node)
      self.graph_dict.update({main_node: connected_nodes})
      return

Unittest:

  def test_add_node(self):
       graph = main.Graph()
       nodes = ('a', 'b', 'c', 'd')
       graph.add_node(nodes)
       self.assertEqual(True,False)```


verblox
  • 53
  • 6

1 Answers1

0

You are not comparing apples to apples.

You describe two ways of calling add_node() and one of them is wrong.

Perhaps you meant:

graph.add_node(*nodes)
quamrana
  • 37,849
  • 12
  • 53
  • 71