Example #1
0
 def definitions(self):
     """
     return a list of all the definitions that are included in this library
     """
     return ListView(self._definitions)
Example #2
0
 def libraries(self):
     """Get a list of all libraries included in the netlist."""
     return ListView(self._libraries)
Example #3
0
 def pins(self):
     """Get a list of the pins that are in the port"""
     return ListView(self._pins)
Example #4
0
 def cables(self):
     """
     Get the cables that are instanced in this definition.
     """
     return ListView(self._cables)
Example #5
0
 def wires(self):
     """Gets a list of wires that are in this cable"""
     return ListView(self._wires)
Example #6
0
 def children(self):
     """
     Return a list of all instances instantiated in this definition
     """
     return ListView(self._children)
Example #7
0
 def ports(self):
     """
     Get the ports that are instanced in this definition
     """
     return ListView(self._ports)
Example #8
0
 def pins(self):
     """The a list of pins that the wire is connected to"""
     return ListView(self._pins)
Example #9
0
 def wires(self):
     '''get a list of wires that are in this cable'''
     return ListView(self._wires)
Example #10
0
 def test_lt(self):
     self.assertTrue(self.list_view < ListView(list(range(11))))
     self.assertTrue(self.list_view < list(range(11)))
Example #11
0
 def test_le(self):
     self.assertTrue(self.list_view <= ListView(list(range(10))))
     self.assertTrue(self.list_view <= list(range(10)))
Example #12
0
 def test_gt(self):
     self.assertTrue(self.list_view > ListView(list(range(9))))
     self.assertTrue(self.list_view > list(range(9)))
Example #13
0
 def setUp(self) -> None:
     self.list_view = ListView(list(range(10)))
Example #14
0
class TestListView(unittest.TestCase):
    def setUp(self) -> None:
        self.list_view = ListView(list(range(10)))

    def test_getitem(self):
        self.assertTrue(self.list_view[0] == 0)

    def test_contains(self):
        self.assertTrue(5 in self.list_view)

    def test_comparison(self):
        list_copy = list(range(10))
        self.assertEqual(self.list_view, list_copy)
        empty_list = list()
        self.assertNotEqual(self.list_view, empty_list)

    def test_iter(self):
        aggregate = 0
        for item in self.list_view:
            aggregate += item
        self.assertEqual(sum(range(10)), aggregate)

    def test_len(self):
        self.assertEqual(len(self.list_view), 10)

    def test_reversed(self):
        self.assertEqual(next(iter(reversed(self.list_view))), 9)

    def test_copy(self):
        self.assertEqual(self.list_view, self.list_view.copy())

    def test_count(self):
        self.assertEqual(self.list_view.count(5), 1)

    def test_index(self):
        self.assertEqual(self.list_view.index(5), 5)

    def test_slice(self):
        self.assertEqual(self.list_view[1:4], list(range(1, 4)))

    def test_multiply(self):
        self.assertEqual(len(self.list_view * 2), 20)
        self.assertEqual(len(2 * self.list_view), 20)

    def test_add(self):
        result = list(range(10, 20)) + self.list_view
        print(result)
        self.assertEqual(len(result), 20)
        result = self.list_view + list(range(10, 20))
        print(result)
        self.assertEqual(len(result), 20)

    @unittest.expectedFailure
    def test_multiply_assignment(self):
        self.list_view *= 2

    @unittest.expectedFailure
    def test_add_assignment(self):
        self.list_view += list(range(10))

    def test_ge(self):
        self.assertTrue(self.list_view >= ListView(list(range(10))))
        self.assertTrue(self.list_view >= list(range(10)))

    def test_gt(self):
        self.assertTrue(self.list_view > ListView(list(range(9))))
        self.assertTrue(self.list_view > list(range(9)))

    def test_le(self):
        self.assertTrue(self.list_view <= ListView(list(range(10))))
        self.assertTrue(self.list_view <= list(range(10)))

    def test_lt(self):
        self.assertTrue(self.list_view < ListView(list(range(11))))
        self.assertTrue(self.list_view < list(range(11)))

    def test_repr(self):
        self.assertEqual(repr(self.list_view), repr(list(range(10))))

    def test_str(self):
        self.assertEqual(str(self.list_view), str(list(range(10))))

    def test_hash(self):
        self.assertRaises(TypeError, hash, self.list_view)