python Python备忘单

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python备忘单相关的知识,希望对你有一定的参考价值。

# importing
import sha				# import the the sha module
from animal import Animal		# import the Animal class from animal.py

# unit testing
# http://docs.python.org/3/library/unittest.html
import unittest

class AnimalTest(unittest.TestCase):

	def setUp(self):
		pass
	
	def tearDown(self):
		pass

	def test_grow(self):
		lion = Animal('Lion')
		self.assertEqual(lion.weight, 5, "Animal should start at 5 lbs")
		lion.grow()
		self.assertEqual(lion.weight, 6, "Animal weight should increase by 1 when grow is called")

unittest.main()			# run unit tests
python3 -m unittest		# run unit tests from the command line
python3 -m unittest animal	# run unit tests in the animal module from the command line

以上是关于python Python备忘单的主要内容,如果未能解决你的问题,请参考以下文章

python Python备忘单

python Codewars Python测试框架的备忘单

python Spark Dataframes的备忘单(使用Python)

python pyspark rdd备忘单

python pyspark sql备忘单

python 烧瓶登录备忘单