override fun createCourse()

in intellij-plugin/Edu-Python/testSrc/com/jetbrains/edu/python/slow/checker/PyCheckErrorsTest.kt [24:87]


  override fun createCourse(): Course {
    return course(language = PythonLanguage.INSTANCE) {
      lesson {
        eduTask("EduTestsFailed") {
          pythonTaskFile("hello_world.py", """print("Hello, world! My name is type your name")""")
          pythonTaskFile("tests.py", """print("#educational_plugin test_type_used FAILED + error happened")""")
        }
        eduTask("EduNoTestsRun") {
          pythonTaskFile("hello_world.py", """print("Hello, world! My name is type your name")""")
          pythonTaskFile("tests.py", """print("")""")
        }
        eduTask("SyntaxError") {
          /**
           * We do not have test_helper.py here because it is generated automatically
           * @see com.jetbrains.edu.python.learning.newproject.PyCourseProjectGenerator.createAdditionalFiles
           * */
          @Suppress("PyStatementEffect")
          pythonTaskFile("hello_world.py", """This is not Python code""")
          pythonTaskFile("tests.py", """
            from test_helper import run_common_tests, failed, passed, get_answer_placeholders
            run_common_tests()
            """)
        }
        eduTask("SyntaxErrorFromUnittest") {
          @Suppress("PyStatementEffect")
          pythonTaskFile("hello_world.py", """This is not Python code""")
          pythonTaskFile("my_unit_tests.py", """
            import unittest
            from hello_world import sum_of_two_digits

            class TestSumOfTwoDigits(unittest.TestCase):
                def test_something(self):
                    self.assertTrue(sum_of_two_digits())

            if __name__ == '__main__':
                unittest.main()
            """)
          pythonTaskFile("tests.py", """
            from test_helper import run_common_tests, failed, passed, import_file
            from unittest import defaultTestLoader, TestResult
            
            module = import_file("my_unit_tests.py")
            test_suite = defaultTestLoader.loadTestsFromModule(module)
            test_result = TestResult()
            test_suite.run(test_result)
            
            if test_result.wasSuccessful():
                passed()
            else:
                failed("Some unit tests failed")
            """)
        }
        eduTask("DoNotEscapeMessageInFailedTest") {
          pythonTaskFile("tests.py", """print("#educational_plugin test_type_used FAILED + <br>")""")
        }
        outputTask("OutputTestsFailed") {
          pythonTaskFile("hello_world.py", """print("Hello, World")""")
          taskFile("output.txt") {
            withText("Hello, World!\n")
          }
        }
      }
    }
  }