Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.assert_ 缩进在 if 或 for 下面断言失败时不能将对应的值信息打印出来 #95

Open
mocobk opened this issue Jun 5, 2021 · 1 comment

Comments

@mocobk
Copy link

mocobk commented Jun 5, 2021

举个例子:

  1. 当 self.assert_ 没有缩进在 if 或 for 下面,断言失败时可以展示断言的实际值 [检查 status_code = 0] assert 200 == 201
    def run_test(self):
        response = self.channel.get(self.uri.uniprorec_publish_range_list)
        self.assert_(f'检查 status_code = 0', response.status_code == 201)
ASSERT: 检查点不通过
  File ".../UniAutoTest/testcases/recommend_list/test.py", line 31, in run_test
    self.assert_(f'检查 status_code = 0', response.status_code == 201)
 [检查 status_code = 0] assert  200 == 201
 +  where 200 = <qt4s.channel.http.HttpResponse object at 0x7f9202e282d0>.status_code
  1. 当 self.assert_ 缩进在 if 下面,断言失败时只展示了异常堆栈信息,未打印出response.status_code实际值
    def run_test(self):
        response = self.channel.get(self.uri.uniprorec_publish_range_list)
        if True:
            self.assert_(f'检查 status_code = 0', response.status_code == 201)
ASSERT: 检查点不通过
  File ".../UniAutoTest/testcases/recommend_list/test.py", line 34, in run_test
    self.assert_(f'检查 status_code = 0', response.status_code == 201)
检查 status_code = 0
@mocobk
Copy link
Author

mocobk commented Jun 12, 2021

其他人都没遇到类似的问题么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant