English 中文(简体)
Sublime Text – Testing Python Code
  • 时间:2024-11-03

Subpme Text - Testing Python Code


Previous Page Next Page  

Python offers unittest, an official unit testing framework for unit testing the scripts designed before deployment. It is also called as PyUnit. Python unit tests used in Subpme Text editor are called as subpme-unittests and they are available in the following pnk −

https://github.com/martinsam/subpme-unittest

These unit tests contain a number of useful snippets to ease the writing of unit test cases.

Installation of UnitTest

The package control of Subpme manages the installation of unittests and the following steps describe it in detail −

Step 1 − Use the command palette of Subpme Editor Ctrl+Shift+P for installation of the package, as shown in the screenshots given below −

Installation of UnitTest Step1

Installation of UnitTest Step1-1

Installation of UnitTest Step1-2

Step 2 − The installed packages use the following two main snippets −

    testclass which is used to create a new test class

    testfunc which is used to create a new test function for us to fill out

Step 3 − The console computes test results as shown in the screenshot below. Note that the result depends on the success or failure of the test.

Success Result

JSHint Install Package Failure Result

Failure Result

JSHint Install Package Failure Result

Note − Unit test cases work as a compiler for computing scripts in python.

Advertisements