Skip to content

Files

Latest commit

Mar 1, 2023
a48c58e · Mar 1, 2023

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 1, 2023
Mar 1, 2023
Mar 1, 2023
Mar 1, 2023

Python Unittest Model

The project utilizes the python unittest model to ensure the functionalities of its models. The following sample script runs a test model: python -m unittest tests/

Basic Example

The unittest module provides a rich set of tools for constructing and running tests. This section demonstrates that a small subset of the tools suffice to meet the needs of most users.

  • Here is a short script to test three string methods:

#!/usr/bin/python3

import unittest

class TestStringMethods(unittest.TestCase):

def test_upper(self): self.assertEqual('foo'.upper(), 'FOO')

def test_isupper(self): self.assertTrue('FOO'.isupper()) self.assertFalse('Foo'.isupper())

def test_split(self): s = 'hello world' self.assertEqual(s.split(), ['hello', 'world']) # check that s.split fails when the separator is not a string with self.assertRaises(TypeError): s.split(2)

if name == 'main': unittest.main()