【问题标题】:"Ran 0 tests in 0.000s "“在 0.000 秒内运行 0 次测试”
【发布时间】:2020-06-29 22:29:12
【问题描述】:

我编写了以下代码来测试我的课程,但出现“在 0.000 中进行 0 次测试”错误:

import unittest

from survey import AnonymousSurvey

class TestAnonymousSurvey(unittest.TestCase):

      def test_store_single_response(self):

         question="Which language did you first learn to speak?"

         my_survey=AnonymousSurvey(question)

         my_survey.store_response('English')

         self.assertIn('English',my_survey.responses)

if __name__=='__main__':

  unittest.main()

【问题讨论】:

  • 向我们展示你是如何运行测试的。
  • 这能回答你的问题吗? Python unittest - Ran 0 tests in 0.000s
  • @FishingCode 该类确实包含一个以“test”开头的方法名称,所以可能不是这里的原因。
  • @JohnGordon 你到底是什么意思?
  • 你必须输入 some 命令,输出“Ran 0 tests in 0.000”...

标签: python


【解决方案1】:

我认为您必须为question 提供输入,AnonymousSurvery(question) 初始化调查:

     getResponse = input("Which language did you first learn to speak?")
     latestResponse = my_survery.store_response(getResponse)  

     self.assertIn("English", latestResponse)

继续下面的主要功能...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-12
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多