Code Monkey home page Code Monkey logo

utx's Issues

单个执行用例,异常,麻烦大佬有时间帮忙分析一下

操作就是单个执行unittest中的TestCase

Traceback (most recent call last):
File "C:\Python36\Lib\unittest\case.py", line 59, in testPartExecutor
yield
File "C:\Python36\Lib\unittest\case.py", line 605, in run
testMethod()
File "C:\Python36\Lib\unittest\loader.py", line 34, in testFailure
raise self._exception
File "C:\Python36\Lib\unittest\loader.py", line 168, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: type object 'ReadingProcess' has no attribute 'test_createTask'

希望可以去掉强制命名,文件需要以test开头

Traceback (most recent call last):
File "", line 1, in
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/lincanyi/Project/interface-tools/lxtx/case/debugCase.py", line 13, in
runner.run_test(report_title='接口自动化测试报告')
File "/Users/lincanyi/Project/interface-tools/venv/lib/python3.8/site-packages/utx-0.0.7-py3.8.egg/utx/runner.py", line 222, in run_test
_TestRunner(report_dir=report_dir, report_title=report_title).run(suite)
File "/Users/lincanyi/Project/interface-tools/venv/lib/python3.8/site-packages/utx-0.0.7-py3.8.egg/utx/runner.py", line 118, in run
style_1.build_report(file_path, result_data)
File "/Users/lincanyi/Project/interface-tools/venv/lib/python3.8/site-packages/utx-0.0.7-py3.8.egg/utx/report/style_1.py", line 377, in build_report
test_pass_per="{:.2%}".format(data['testPass'] / data['testAll']),
ZeroDivisionError: division by zero

py文件不以开头test开头会报0错误

I got this error : ZeroDivisionError: division by zero , so that the report can't create

2019-07-08 17:12:12,761 INFO 开始测试,用例数量总共3个,跳过0个,实际运行3个
2019-07-08 17:12:12,761 INFO Time Elapsed: 0:00:00.000198
Traceback (most recent call last):
File "/Users/user/app/interface/test-interfaces.git/WORK/AVN_Test/Sample.py", line 84, in
runner.run_test(report_title='接口自动化测试报告')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/utx-0.0.7-py3.7.egg/utx/runner.py", line 222, in run_test
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/utx-0.0.7-py3.7.egg/utx/runner.py", line 118, in run
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/utx-0.0.7-py3.7.egg/utx/report/style_1.py", line 377, in build_report
ZeroDivisionError: division by zero

Process finished with exit code 1

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

现象

  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):
        ......

关于unittest 排序的问题

我搜索unittest 用例排序找到了你的代码,但是我发现一个问题,就是在获取class的函数属性的时候,其实是在从字典里拿数据,字典是无序的,那你拿到的函数根本不是按照添加的顺序排列的,所以你做的重命名也是在对本身顺序错误的列表进行重命名啊,

问题在于这里funcs_dict,这是一个字典,你迭代一个字典,每次的结果都是不一样的,这不是列表

@staticmethod
    def filter_test_case(funcs_dict):
        funcs = dict()
        cases = dict()
        for i in funcs_dict:
            if i.startswith("test_"):
                cases[i] = funcs_dict[i]
            else:
                funcs[i] = funcs_dict[i]

        return funcs, cases

我自己单纯只提供排序的元类,如下,也是有相同的问题,不知道这个怎么处理

class Meta(type):
    def __new__(cls, name, parents, attrs):
        LONG = 4
        id = 1
        _attrs = {}
        for k, v in attrs.items():
            if k.startswith('test_'):
                id_str = str(id).zfill(LONG)
                _k = k.replace('test_', 'test_{}_'.format(id_str))
                _attrs[_k] = v
                id += 1
            else:
                _attrs[k] = v
        return type.__new__(cls, name, parents, _attrs)

attrs.items() 是把一个无序的字典变成的列表,这个列表迭代也无法得到按照函数添加的顺序排序,不知道你是怎么做到可以按照添加的顺序来排序的?反正我看代码没有看出来

python3.7 使用不起

python setup.py install
提示
python: can't open file 'setup.py': [Errno 2] No such file or directory

控制台打印的测试用例数量和index不对

2019-10-19 16:35:17,300 WARNING doctest.test_skip没有用例描述
2019-10-19 16:35:17,319 WARNING test_baidu.test_timedistance_v0没有用例描述
2019-10-19 16:35:17,319 INFO 开始测试,用例数量总共10个,跳过0个,实际运行10个
2019-10-19 16:35:17,420 INFO start to test test_baidu.test_timedistance_v0 (2/10)
2019-10-19 16:35:17,519 INFO start to test test_baidu.test_timedistance_v0 (3/10)
2019-10-19 16:35:17,619 INFO start to test test_tattle.test_get_battle_reward (9/10)
2019-10-19 16:35:17,720 INFO start to test test_tattle.test_get_battle_reward (10/10)
2019-10-19 16:35:17,819 INFO start to test test_tattle.test_bless (4/10)
2019-10-19 16:35:17,920 INFO start to test test_tattle.test_bless (5/10)
2019-10-19 16:35:18,019 INFO start to test test_tattle.test_receive_bless_box (6/10)
2019-10-19 16:35:18,119 INFO start to test test_tattle.test_receive_bless_box (7/10)
2019-10-19 16:35:18,220 INFO start to test test_tattle.test_receive_bless_box (8/10)
2019-10-19 16:35:18,220 INFO Time Elapsed: 0:00:00.900000

真实情况是用例只有9个,统计结果是10个,index也有点问题,不是从第1个开始计数

log没有换行,可读性差

_logger_handler.setFormatter(logging.Formatter('%(asctime)s %(message)s' + '\n'))

建议增加换行
\utx-0.0.2-py3.6.egg\utx\log.py
line:13

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.