nodes = list(OpenMaya.MFnDependencyNode.bnFind(pattern='n*de'))
        self.assertEqual(len(nodes), 4)
        self.assertTrue(all(type(node) is OpenMaya.MFnDependencyNode for node in nodes))
        self.assertEqual(sorted(node.name() for node in nodes), ['n0de', 'node', 'node', 'node'])

        nodes = list(OpenMaya.MFnDependencyNode.bnFind(pattern='default*Set'))
        self.assertEqual(len(nodes), 2)
        self.assertTrue(all(type(node) is OpenMaya.MFnDependencyNode for node in nodes))
        self.assertEqual(sorted(node.name() for node in nodes), ['defaultLightSet', 'defaultObjectSet'])

    def testBnGet(self):
        self.assertIsNone(OpenMaya.MFnDependencyNode.bnGet(pattern='node'))
        self.assertIsNone(OpenMaya.MFnDependencyNode.bnGet(pattern='child_*'))

        node = OpenMaya.MFnDependencyNode.bnGet(pattern='awesome:light')
        self.assertIsInstance(node, OpenMaya.MFnDependencyNode)
        self.assertEqual(node.name(), 'awesome:light')

        node = OpenMaya.MFnDependencyNode.bnGet(pattern='n0de')
        self.assertIsInstance(node, OpenMaya.MFnDependencyNode)
        self.assertEqual(node.name(), 'n0de')

        node = OpenMaya.MFnDependencyNode.bnGet(pattern='time1')
        self.assertIsInstance(node, OpenMaya.MFnDependencyNode)
        self.assertEqual(node.name(), 'time1')


if __name__ == '__main__':
    from tests.run import run
    run('__main__')
示例#2
0
        a = DynamicArray(0, numpy.dtype(numpy.int8))
        self.assertEqual(len(a), 0)
        self.assertEqual(len(a.data), 0)

        a.extend([0, 1, 4, 9])
        self.assertEqual(len(a), 4)
        self.assertEqual(a.data.tolist(), [0, 1, 4, 9])

        a.extend([2, 4, 6, 8])
        self.assertEqual(len(a), 8)
        self.assertEqual(a.data.tolist(), [0, 1, 4, 9, 2, 4, 6, 8])

        a.extend(numpy.arange(4))
        self.assertEqual(len(a), 12)
        self.assertEqual(a.data.tolist(), [0, 1, 4, 9, 2, 4, 6, 8, 0, 1, 2, 3])

    def test_clear(self):
        a = DynamicArray(0, numpy.dtype(numpy.int8))
        a.extend([0, 1, 4, 9])
        self.assertEqual(len(a), 4)
        self.assertEqual(a.data.tolist(), [0, 1, 4, 9])

        a.clear()
        self.assertEqual(len(a), 0)
        self.assertEqual(a.data.tolist(), [])


if __name__ == '__main__':
    from tests.run import run
    run('__main__')