python自动化测试之连接几组测试包实例

【自取】最近整理的,有需要可以领取学习:

python自动化测试之连接几组测试包实例

本文给出了一个实例,描述了在Python自动化测试中连接多组测试包的方法,供大家参考。具体方法如下:

[En]

In this paper, an example is given to describe the method of connecting several groups of test packages in python automated testing, which is shared for your reference. The specific methods are as follows:

python自动化测试之连接几组测试包实例

具体代码如下:

[En]

The specific code is as follows:

class RomanNumeralConverter(object):
def init(self):
self.digit_map = {“M”:1000, “D”:500, “C”:100, “L”:50, “X”:10, “V”:5, “I”:1}

def convert_to_decimal(self, roman_numeral):
val = 0
for char in roman_numeral:
val = self.digit_map[char]
return val

import unittest
class RomanNumeralConverterTest(unittest.TestCase):
def setUp(self):
self.cvt = RomanNumeralConverter()

def test_parsing_millenia(self):
self.assertEquals(1000, self.cvt.convert_to_decimal(“M”))

def test_parsing_century(self):
self.assertEquals(100, self.cvt.convert_to_decimal(“C”))

class RomanNumeralConverterCombo(unittest.TestCase):
def setUp(self):
self.cvt = RomanNumeralConverter()

def test_multi_millenia(self):
self.assertEquals(4000, self.cvt.convert_to_decimal(“MMMM”))

def test_add_up(self):
self.assertEquals(2010, self.cvt.convert_to_decimal(“MMX”))

if name == “main“:
suite1 = unittest.TestLoader().loadTestsFromTestCase(RomanNumeralConverterTest)
suite2 = unittest.TestLoader().loadTestsFromTestCase(RomanNumeralConverterCombo)
suite = unittest.TestSuite([suite1, suite2])
unittest.TextTestRunner(verbosity=2).run(suite)

运行结果如下:

[En]

The running results are as follows:

test_parsing_century (main.RomanNumeralConverterTest) … ok
test_parsing_millenia (main.RomanNumeralConverterTest) … ok
test_add_up (main.RomanNumeralConverterCombo) … ok
test_multi_millenia (main.RomanNumeralConverterCombo) … ok

Original: https://www.cnblogs.com/amengduo/p/9586230.html
Author: 刘小子
Title: python自动化测试之连接几组测试包实例

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/7398/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

发表回复

登录后才能评论
免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部