python - Django Test Case Can't run method -


i getting started django, may stupid, not sure google @ point.

i have method looks this:

def get_user(self,user):     return utilities.get_userprofile(user) 

the method looks this:

@staticmethod def get_userprofile(user):     return userprofile.objects.filter(user_auth__username=user)[0] 

when include in view, fine. when write test case use of methods inside utility class, none back:

two test cases:

def test_stack_overflow(self):     = objname()     print(a.get_user('admin'))  def test_utility(self):     print(utilities.get_user('admin')) 

results:

creating test database alias 'default'... none ..none . ---------------------------------------------------------------------- 

can tell me why working in view, not working inside of test case , not generate error messages?

thanks

verify whether unit test comply followings,

  1. testclass must written in file name test*.py
  2. testclass must have been subclassed unittest.testcase
  3. testclass should have setup function create objects(usually done in way, objects creation can happen in test functions well) in database
  4. testclass functions should start test identified , run ./manage.py test command
  5. testclass may have teardown end unit test case.

test case execution process:

when run ./manage.py test django sets test_your_database_name , creates objects mentioned in setup function(usually) , starts executing test functions in order of placement inside class , once when test functions executed, looks teardown function executes if present in test class , destroys test database.

it may be because might not have invoked objects creation in setup function or elsewhere in testclass.

can kindly post entire traceback , test file better?


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -