How to use test_getdict method in tox

Best Python code snippet using tox_python

test_circuit.py

Source:test_circuit.py Github

copy

Full Screen

1import unittest2from itertools import product3from obfusc8.circuit import *4class TestCircuit(unittest.TestCase):5 def setUp(self):6 self.inputLength = 47 self.inputs = [Input('x') for _ in range(0, self.inputLength)]8 self.a1 = AndGate(self.inputs[0], self.inputs[1])9 self.n1 = NotGate(self.a1)10 self.n2 = NotGate(self.inputs[2])11 self.a2 = AndGate(self.n2, self.inputs[3])12 self.a3 = AndGate(self.n1, self.a2)13 self.circuit = Circuit(self.a3)14 def tearDown(self):15 self.inputLength = None16 self.inputs = None17 self.c1 = None18 def test_init(self):19 self.assertEqual(self.inputs, self.circuit.inputs, 'input detection broken')20 def test_countGates_basic(self):21 self.assertEqual(5, self.circuit.countGates(), 'wrong gate count')22 def test_countGates_not(self):23 self.assertEqual(2, self.circuit.countGates(0), 'wrong not gate count')24 def test_countGates_and(self):25 self.assertEqual(3, self.circuit.countGates(1), 'wrong and gate count')26 def test_countGates_add(self):27 self.assertEqual(self.circuit.countGates(), self.circuit.countGates(0)+self.circuit.countGates(1), 'complete gate count unequal to not + and Gates')28 def test_evaluate(self):29 for test in list(product([0,1], repeat=self.inputLength)):30 test = list(test)31 correct = (not (test[0] and test[1]) and (not test[2] and test[3]))32 self.assertEqual(correct, self.circuit.evaluate(test), 'Wrong evaluation on input %s. Was %s instead of %s'%(test, self.circuit.evaluate(test), correct))33 def test_getDependency(self):34 resultDict = {self.a3.id: set([self.n1.id, self.a2.id]), self.n1.id:set([self.a1.id]), self.a2.id: set([self.n2.id]), self.a1.id: set([]), self.n2.id: set([])}35 self.assertEqual(resultDict, self.circuit.getDependency(), 'wrong dependency dictionary')36 def test_getDepth(self):37 self.assertEqual(3, self.circuit.getDepth(), 'incorrect depth on example circuit')38 def test_getDict(self):39 resultDict = {self.a3.id: self.a3, self.a2.id: self.a2, self.a1.id: self.a1, self.n2.id: self.n2, self.n1.id: self.n1}40 self.assertEqual(resultDict, self.circuit.getDict(), 'wrong mapping dict')41 def test_str(self):42 self.assertEqual('(-(x0&x1)&(-x2&x3))', str(self.circuit), 'string conversion does not match')43class TestInput(unittest.TestCase):44 def setUp(self):45 self.input = Input('x0')46 def tearDown(self):47 self.input = None48 def test_value_zero_after_init(self):49 self.assertEqual(0, self.input.evaluate(), 'initial value not zero')50 def test_str_returns_name(self):51 self.assertEqual('x0', str(self.input))52 def test_countGates_returns_zero(self):53 self.assertEqual(0, self.input.countGates(None), 'countGates does not return zero')54 def test_getDepth_returns_zero(self):55 self.assertEqual(0, self.input.getDepth(), 'getDepth does not return zero')56 def test_getType_correctness(self):57 self.assertEqual(-1, self.input.getType(), 'getType does not return -1')58 def test_set_and_evaluate(self):59 self.input.set(1)60 self.assertEqual(1, self.input.evaluate(), 'evaluation with value set to 1 does not return 1')61 self.input.set(0)62 self.assertEqual(0, self.input.evaluate(), 'evaluation with value set to 0 does not return 0')63class TestNotGate(unittest.TestCase):64 def setUp(self):65 self.input = Input('x0')66 self.gate = NotGate(self.input)67 def tearDown(self):68 self.gate = None69 def test_init(self):70 self.assertEqual(self.input, self.gate.input1, 'input not assigned to input1')71 def test_str(self):72 self.assertEqual('-x0', str(self.gate), 'string conversion does not match')73 def test_countGates_with_type_zero(self):74 self.assertEqual(1, self.gate.countGates(0), 'countGates with type 0 incorrect')75 def test_countGates_with_type_one(self):76 self.assertEqual(0, self.gate.countGates(1), 'countGates with type 1 incorrect')77 def test_evaluate(self):78 self.input.set(0)79 self.assertEqual(1, self.gate.evaluate(), 'Wrong evaluation on input [0]. Was %s instead of 1'%self.gate.evaluate())80 self.input.set(1)81 self.assertEqual(0, self.gate.evaluate(), 'Wrong evaluation on input [1]. Was %s instead of 0'%self.gate.evaluate())82 @unittest.skip('not important')83 def test_getDependency(self):84 # and_gate = AndGate(input1, input2)85 # self.assertEqual(expected, and_gate.getDependency())86 assert False # TODO: implement your test here87 def test_getDepth(self):88 self.assertEqual(1, self.gate.getDepth())89 @unittest.skip('not important')90 def test_getDict(self):91 # and_gate = AndGate(input1, input2)92 # self.assertEqual(expected, and_gate.getDict())93 assert False # TODO: implement your test here94 def test_getInputs(self):95 self.assertEqual([self.input], self.gate.getInputs(), 'getInputs result not identical to initial inputs')96 def test_getType(self):97 self.assertEqual(0, self.gate.getType())98class TestAndGate(unittest.TestCase):99 def setUp(self):100 self.inputLength = 2101 self.inputs = [Input('x') for _ in range(0, self.inputLength)]102 self.gate = AndGate(self.inputs[0], self.inputs[1])103 self.circuit = Circuit(self.gate)104 def tearDown(self):105 self.inputLength = None106 self.inputs = None107 self.gate = None108 def test_init(self):109 self.assertEqual(self.inputs[0], self.gate.input1, 'left input not assigned to input1')110 self.assertEqual(self.inputs[1], self.gate.input2, 'right input not assigned to input2')111 def test_str(self):112 self.assertEqual('(x0&x1)', str(self.gate), 'string conversion does not match')113 def test_countGates_with_type_zero(self):114 self.assertEqual(0, self.gate.countGates(0), 'countGates with type 0 incorrect')115 def test_countGates_with_type_one(self):116 self.assertEqual(1, self.gate.countGates(1), 'countGates with type 1 incorrect')117 def test_evaluate(self):118 for test in list(product([0,1], repeat=self.inputLength)):119 test = list(test)120 correct = (test[0] and test[1])121 self.assertEqual(correct, self.circuit.evaluate(test), 'Wrong evaluation on input %s. Was %s instead of %s'%(test, self.circuit.evaluate(test), correct))122 @unittest.skip('not important')123 def test_getDependency(self):124 # and_gate = AndGate(input1, input2)125 # self.assertEqual(expected, and_gate.getDependency())126 assert False # TODO: implement your test here127 def test_getDepth(self):128 self.assertEqual(1, self.gate.getDepth())129 @unittest.skip('not important')130 def test_getDict(self):131 # and_gate = AndGate(input1, input2)132 # self.assertEqual(expected, and_gate.getDict())133 assert False # TODO: implement your test here134 def test_getInputs(self):135 self.assertEqual(self.inputs, self.gate.getInputs(), 'getInputs result not identical to initial inputs')136 def test_getType(self):137 self.assertEqual(1, self.gate.getType())138if __name__ == '__main__':...

Full Screen

Full Screen

test_AccessGetter.py

Source:test_AccessGetter.py Github

copy

Full Screen

1from unittest import TestCase2import dataencryptor3from pathlib import Path4import os5print("======================\nStarting unit tests...")6class TestAccessGetter(TestCase):7 def test_initAccessgetter(self):8 self.assertIsNotNone(dataencryptor.DataEncryptor())9 self.assertIsNotNone(dataencryptor.DataEncryptor("Test.json"))10 def test_getDict(self):11 handle = open(str(Path.home()) + "/.ssh/encrypted-data/unittest.json", 'w+')12 handle.write("{\13 \"Test1\":\"Value1\",\14 \"Test2\":\"Value2\",\15 \"Test3\":\"AbsolutelyNotValue3\"}")16 handle.close()17 ag = dataencryptor.DataEncryptor("./unittest.json")18 dict = ag.getDict()19 self.assertIsNotNone(dict)20 self.assertTrue(dict["Test3"] == "AbsolutelyNotValue3")...

Full Screen

Full Screen

test_getdict.py

Source:test_getdict.py Github

copy

Full Screen

1# Copyright 2020 Silicon Compiler Authors. All Rights Reserved.2import siliconcompiler3def test_getdict():4 chip = siliconcompiler.Chip('test')5 chip.load_target('freepdk45_demo')6 localcfg = chip.getdict('pdk')7 assert localcfg['freepdk45']['foundry']['value'] == 'virtual'8#########################9if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful