鱼C论坛

 找回密码
 立即注册
查看: 2659|回复: 3

为什么同样一个py文件在pycharm和shell执行的结果不一样?

[复制链接]
发表于 2017-10-25 20:18:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 a1065135230 于 2017-10-25 20:18 编辑

2.png

1.png





如图所示,代码没有作任何改动,但是结果就是不一样,我就搞不明白了
  1. #我是代码
  2. #执行顺序规则——测试类或测试方法的数字与字母顺序 0~9,A-Z
  3. import unittest

  4. class Test1(unittest.TestCase):
  5.     def setUp(self):
  6.         print("Test1 start")

  7.     def test_c(self):
  8.         print("test_c")

  9.     def test_b(self):
  10.         print("test_b")

  11.     def tearDown(self):
  12.         print("test end")

  13. class Test2(unittest.TestCase):
  14.     def setUp(self):
  15.         print("Test2 start")

  16.     def test_d(self):
  17.         print("test_d")

  18.     def test_a(self):
  19.         print("test_a")

  20.     def tearDown(self):
  21.         print("Test2 end")

  22. if __name__ == '__main__':
  23.     # unittest.main()
  24.     suite=unittest.TestSuite()      #好像写了这一段代码也不会改变执行顺序
  25.     suite.addTest(Test2("test_d"))
  26.     suite.addTest(Test1("test_b"))
  27.     suite.addTest(Test2("test_a"))
  28.     suite.addTest(Test1("test_c"))

  29.     runner=unittest.TextTestRunner()
  30.     runner.run(suite)
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-10-25 20:25:02 | 显示全部楼层

回帖奖励 +2 鱼币

不清楚
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-10-25 20:59:34 | 显示全部楼层

回帖奖励 +2 鱼币

不一样吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-10-26 09:06:45 | 显示全部楼层

回帖奖励 +2 鱼币

图片看不清,哪里不一致了?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-12-25 13:39

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表