Esempio n. 1
0
	def test_get_fromvalue(self):
		var= {1:"a",2:"b",3:"c"}
		test=lzdict(var)
		self.assertEqual(test.get_fromvalue("a"),[1])
		var = {1:"a",2:"b",3:"a","a":"a"}
		test= lzdict(var)
		self.assertEqual(test.get_fromvalue("a"),[1,3,"a"])
Esempio n. 2
0
	def test_swap(self):
		var= {1:2,2:3,3:4,4:5}
		test=lzdict(var)
		self.assertEqual(test.swap,{2:1,3:2,4:3,5:4})
		var = {1:"a",2:"b",3:"c"}
		test= lzdict(var)
		self.assertEqual(test.swap,{"a":1,"b":2,"c": 3})
Esempio n. 3
0
	def test_randitems(self):
		var = {1:"a",2:"b",3:"c",4:"d"}
		test=lzdict(var)
		_l = random.randrange(1,10)
		MSGSTRING=f"""\

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
For test lzdict.randitems:
Random items will not duplicate therefore the length will not be equal
Full dict: {test}
Random item amount: {_l}
Random items: {test.randitems(_l)}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"""
		with open(OUTPUTFILE,"a") as file:
			print(MSGSTRING,file=file)
		self.assertTrue(all([i in var for i in test.randitems(_l)]))
Esempio n. 4
0
	def test_find_invalues(self):
		var= {"true1":"text1","false1":"text2","true2":"case1","false2":"case2"}
		test=lzdict(var)
		self.assertEqual(test.find_invalues("1$"),{"true1":"text1","true2":"case1"})
		self.assertEqual(test.find_invalues("^case").listkeys,["true2","false2"])
Esempio n. 5
0
	def test_find_inkeys(self):
		var = {"abcde":"true1","apple":"false1","aberaham":"true2","amplitude":"false2"}
		test= lzdict(var)
		self.assertEqual(test.find_inkeys("^ab"),{"abcde":"true1","aberaham":"true2"})
		self.assertEqual(test.find_inkeys("^a.+e$").listvalues,["true1","false1","false2"])
Esempio n. 6
0
	def test_listvalues(self):
		var = {1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i"}
		test=lzdict(var)
		self.assertEqual(test.listvalues,["a","b","c","d","e","f","g","h","i"])
		self.assertTrue(isinstance(test.listvalues,(lzlist)))
Esempio n. 7
0
	def test_listkeys(self):
		var = {1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i"}
		test=lzdict(var)
		self.assertEqual(test.listkeys, [1,2,3,4,5,6,7,8,9])
		self.assertTrue(isinstance(test.listkeys,(lzlist)))