TypeError: 'module' object is not callable

import unittest

from base import BaseMethod
from page.login.LoginClass import LoginClass


class TestLogin(unittest.TestCase):

def test_01(self):
print("开始登录")
BaseMethod().getUrl("https://crmadmin.peakscrm.com")
LoginClass().setUsername("admin")
LoginClass().setPwd("admin987654321")
LoginClass().login()
print("登录成功")



运行之后报错;TypeError: 'module' object is not callable
解决:
可以看到BaseMethod.py是一个模块,那么,这里的问题在于 BaseMethod()是调用一个函数,而不是调用一个模块
改成可成功调用

from base.BaseMethod import BaseMethod
from page.login.LoginClass import LoginClass


class TestLogin(unittest.TestCase):

def test_01(self):
print("开始登录")
     BaseMethod.BaseMethod().getUrl("https://crmadmin.peakscrm.com")
        LoginClass().setUsername("admin")
LoginClass().setPwd("admin987654321")
LoginClass().login()
print("登录成功")
原文地址:https://www.cnblogs.com/hqsbrx/p/14812279.html