jianbing / utx

对Python unittest的功能进行了扩展(用例排序,分组,数据驱动,可视化报告等)
MIT License
145 stars 59 forks source link

AttributeError: 'NoneType' object has no attribute '__case_tag__' #11

Open ssfanli opened 4 years ago

ssfanli commented 4 years ago

现象

  1. 重写unittest的init、setUpClass 和 tearDownClass到BaseUnittest
  2. 在HomePageTest 中继承
  3. 用tag标签

运行报错如下

File "/Users/ssfanli/Myfolder/pyproj/work/YSPCheckListAndroid/case/test_1_home_page.py", line 17, in <module>
    class HomePageTest(BaseUnittest):
  File "/Users/ssfanli/Myfolder/pyproj/work/YSPCheckListAndroid/utx/core.py", line 220, in __new__
    setattr(test_case, CASE_TAG_FLAG, {Tag.ALL})  # 没有指定tag的用例,默认带有tag:ALL
AttributeError: 'NoneType' object has no attribute '__case_tag__'

case片段

class HomePageTest(BaseUnittest):

    def setUp(self) -> None:
        self.hp = HomePage(self.d)

    def tearDown(self) -> None:
        self.hp.auto_back()

    @tag(Tag.SMOKE)
    def test_recommend(self):
        ......