Home > other >  Why use python unittest framework getAttributeError sometimes run time report?
Why use python unittest framework getAttributeError sometimes run time report?

Time:09-23

About the code structure is as follows, sometimes can run normally, sometimes complains, said the class in the User cannot find test_user1 this property, the debug the along while also didn't find the reason, ask the great spirit guide!!!!!!
The import unittest
The import of DDT
Testdata=HTTP://https://bbs.csdn.net/topics//{}, {}, {}
@ DDT. DDT
The class User (unittest. TestCase) :

@ classmethod
Def setUpClass (CLS) :
Pass
@ classmethod
Def tearDownClass (CLS) :
Pass

Testdata @ DDT. Data (*)
Def test_user1 (self, data) :
XXX
Try:
Self. AssertEqual (a, b)
Except the Exception as e:
Raise e

If __main__=="__main__ ':
Testunit. The main ()

CodePudding user response:

Your code is a little problem, you perform this, if there are any errors, sent error message posted
 
The import unittest
The import of DDT
Testdata=HTTP://https://bbs.csdn.net/topics//{}, {}, {}

@ DDT. DDT
The class User (unittest. TestCase) :
@ classmethod
Def setUpClass (CLS) :
Pass
@ classmethod
Def tearDownClass (CLS) :
Pass

Testdata @ DDT. Data (*)
Def test_user1 (self, data) :
A=1
B=1
Try:
Self. AssertEqual (a, b)
Except the Exception as e:
Raise e

If __name__=="__main__ ':
Unittest. The main ()

CodePudding user response:

reference 1/f, ice all over the sky the wind response:
your code a little question, do you perform this, if there are any errors, sent error message posted
 
The import unittest
The import of DDT
Testdata=HTTP://https://bbs.csdn.net/topics//{}, {}, {}

@ DDT. DDT
The class User (unittest. TestCase) :
@ classmethod
Def setUpClass (CLS) :
Pass
@ classmethod
Def tearDownClass (CLS) :
Pass

Testdata @ DDT. Data (*)
Def test_user1 (self, data) :
A=1
B=1
Try:
Self. AssertEqual (a, b)
Except the Exception as e:
Raise e

If __name__=="__main__ ':
Unittest. The main ()


Post your code to run there is no problem, just my code I posted the main structure, not the actual code, I am sure not code format problem caused by the actual code is a bit much, bad to stick out, this problem occurs sometimes, sometimes not happened, I want to ask anyone met the similar problem,
  • Related