0

so i have this method here inside a class Foo

Position = namedTuple('Position', ['row', 'column'])

class Foo:
    ...
      def hasObject(self, position:Position)->bool:

i'm trying to write a unit test for this method and so far it looks like this:

def test_hasObject_true(self):
  state = Foo()
  self.assertTrue(state.hasObject(whatDoIPutHereIfIWantToReferToThePosition) , "hasObject is unable to return a true")

i don't know what to put in the parameters of that last line to refer to the position in hasObject since it's not a part of the class Foo. my impression is that since the original file already contains from collections import namedtuple we wouldn't have to rewrite this same line of code for the unit test since the unit test imports the original file anyways

sorry im new to python can someone help

minh anh b
  • 51
  • 4
  • If you want to test `hasObject`, then you have to pass it a position. I don't know the semantics of your class, but I presume a freshly created `Foo` has no objects, so anything you pass should return false `like state.hasObject(Position(5,5))`. You can import `Position` the same way you imported `Foo`. – Tim Roberts Sep 25 '22 at 00:43

0 Answers0