0

In the following code, "_get_classes" method works fine but "_get_tests" throws the above mentioned error. What am I doing wrong here?

def my_func():
     x = Loader._get_classes("test","number") # This works fine

     y = Loader._get_tests("abc","def","ghi") # This does not work



class Loader(object):
    def _get_classes(f, prefix_class_name=None):
         #code here

    def _get_tests(self, module_name, test_class, prefix_test_name):
         #code here
Ivan Kolesnikov
  • 1,787
  • 1
  • 29
  • 45
Aditya
  • 551
  • 5
  • 26
  • Are you sure the _get_classes() method works fine? x = Loader._get_classes("test","number") # This works fine TypeError: unbound method _get_classes() must be called with Loader instance as first argument (got str instance instead) – tbm Oct 27 '18 at 16:02

1 Answers1

0

You can refer this: unbound method

You have to create an instance of class Loader to call method _get_tests, Example:

loader = Loader()
loader._get_tests("abc", "def", "ghi")

because this method has self in parameter. It means refer instance of class. Method _get_classes does not have self in parameter so it works fine without instance.

rsu8
  • 491
  • 4
  • 10
  • You can call the 'self' parameter anything you like, it's just a convention that it be called self. – tbm Oct 27 '18 at 16:01