Python Programing Lab EXERCISE NO : 15(a) EXERCISE - 15(b)

EXERCISE NO : 15(a)
Description:

The Python unit testing framework, sometimes referred to as “PyUnit,” is a Python languageversion of JUnit, by Kent Beck and Erich Gamma.
unittest supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework. The unittest module provides classes that make it easy to support these qualities for a set of tests.
The unittest module provides a rich set of tools for constructing and running tests.
test case:
A test case is the smallest unit of testing. It checks for a specific response to a particular set of inputs. unittest provides a base class, TestCase, which may be used to create new test cases.

assertTrue:
assertTrue is an assertion method that creates a bool value from the received value and then

evaluating it.
In this program, We will create a module called even.py which consists of a function even_number. We will import this module in another file along with another module unittest.
Here, we will define a function test_fun_even in a class Test_even_numbers. In this function, we are passing a list of all even numbers. If all the numbers are even, then all test cases are satisfied and the output will be OK.

EXERCISE - 15(b)
Description:

In this program, We will create a module called reverse.py which consists of a function reverse_string. We will import this module in another file along with another module unittest.
Here, we will define a function test_fun_string in a class Test_string_equal. In this function, we are passing a list of all strings. If all the strings are palindromes, then all test cases are satisfied then the output will be OK.

No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...