当前位置: 首页>>代码示例>>Python>>正文


Python pxr.Tf类代码示例

本文整理汇总了Python中pxr.Tf的典型用法代码示例。如果您正苦于以下问题:Python Tf类的具体用法?Python Tf怎么用?Python Tf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_EnumConversion

    def test_EnumConversion(self):
        value1 = Tf._Alpha | Tf._Delta
        # Conversions of TfEnum objects to python should retain the correct type.'''
        self.assertIs(Tf._returnsTfEnum(value1), value1)

        # The auto-generated python object should be convertible to the original type.
        Tf._takesTestEnum(value1)
开发者ID:400dama,项目名称:USD,代码行数:7,代码来源:testTfPython.py

示例2: test_PythonSubclassOfCppClass

    def test_PythonSubclassOfCppClass(self):
        class TestPyDerived( Tf.TestCppBase ):
            def TestVirtual(self):
                return 123

        tTestCppBase = Tf.Type.Find( Tf.TestCppBase )
        tTestPyDerived = Tf.Type.Define( TestPyDerived )

        self.assertFalse(tTestCppBase.isUnknown)
        self.assertFalse(tTestPyDerived.isUnknown)

        self.assertEqual(Tf.TestCppBase, tTestCppBase.pythonClass)
        self.assertEqual(tTestCppBase, Tf.Type.Find( Tf.TestCppBase ))

        self.assertIn(TestPyDerived.__name__, tTestPyDerived.typeName)
        self.assertEqual(TestPyDerived, tTestPyDerived.pythonClass)
        self.assertEqual(tTestPyDerived, Tf.Type.Find( TestPyDerived ))
        self.assertEqual(tTestPyDerived, Tf.Type.FindByName( tTestPyDerived.typeName ))
        self.assertEqual((tTestCppBase,), tTestPyDerived.baseTypes)
        self.assertEqual((), tTestPyDerived.derivedTypes)

        self.assertFalse(tTestCppBase.IsA( tTestPyDerived ))
        self.assertTrue(tTestPyDerived.IsA( tTestCppBase ))

        # Test C++ TfType::Find() on a polymorphic base C++ type with a python
        # subclass.
        self.assertNotEqual(tTestPyDerived, tTestCppBase)
        self.assertEqual(tTestCppBase, Tf._TestFindType(Tf.TestCppBase()))
        self.assertEqual(tTestPyDerived, Tf._TestFindType(TestPyDerived()))
开发者ID:JT-a,项目名称:USD,代码行数:29,代码来源:testTfType.py

示例3: StandardTests

 def StandardTests(allowExtraArgs):
     CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs),
                 allowExtraArgs, (), {})
     CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1),
                 allowExtraArgs, (), {'a':1})
     CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1, 2, 3),
                 allowExtraArgs, (), {'a':1, 'b':2, 'c':3})
     CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1, 2, c=3),
                 allowExtraArgs, (), {'a':1, 'b':2, 'c':3})
开发者ID:400dama,项目名称:USD,代码行数:9,代码来源:testTfPython.py

示例4: test_Factory

    def test_Factory(self):
        df = Tf._DerivedFactory()
        self.assertIsInstance(df, Tf._TestDerived)
        self.assertTrue(hasattr(df, '__owner'))
        self.assertEqual((True, 'cpp derived'), Tf._TakesBase(df))
        Tf._TakesReference(df)
        self.assertFalse(hasattr(df, '__owner'))

        self.assertIs(Tf._DerivedNullFactory(), None)
开发者ID:400dama,项目名称:USD,代码行数:9,代码来源:testTfPython.py

示例5: test_Listening

    def test_Listening(self):
        for pkg in args:
            self.assertEqual(pkg[0], testListening(*pkg[1:]))


        lc = listenerClass()
        testSender = Tf._TestDerived()
        listener = Tf.Notice.Register(Tf.Notice, lc.cb, testSender)
        Tf._sendTfNoticeWithSender(testSender)
        self.assertEqual(1, lc.received)
开发者ID:400dama,项目名称:USD,代码行数:10,代码来源:testTfPyNotice.py

示例6: test_boolResult

    def test_boolResult(self):
        result = Tf._TestAnnotatedBoolResult(True, 'This is true')
        self.assertTrue(result)
        self.assertEqual(result.annotation, 'This is true')
        boolResult, annotation = result
        self.assertTrue(boolResult)
        self.assertEqual(annotation, 'This is true')

        result = Tf._TestAnnotatedBoolResult(False, 'This is false')
        self.assertFalse(result)
        self.assertEqual(result.annotation, 'This is false')
        boolResult, annotation = result
        self.assertFalse(boolResult)
        self.assertEqual(annotation, 'This is false')
开发者ID:JT-a,项目名称:USD,代码行数:14,代码来源:testTf_PyAnnotatedBoolResult.py

示例7: test_Callbacks

    def test_Callbacks(self):
        global f1called
        Tf._callback(f1)
        self.assertTrue(f1called)

        self.assertEqual('called to python, return string!', Tf._stringCallback(f2))

        self.assertEqual('got string c++ is calling...', Tf._stringStringCallback(f4))

        with self.assertRaises(TypeError):
            Tf._callback(f3)
        with self.assertRaises(TypeError):
            Tf._stringCallback(f1)
开发者ID:400dama,项目名称:USD,代码行数:13,代码来源:testTfPython.py

示例8: test_StringToLong

    def test_StringToLong(self):

        def checks(val):
            self.assertEqual(Tf.StringToLong(repr(val)), val)
        def checku(val):
            self.assertEqual(Tf.StringToULong(repr(val)), val)

        # A range of valid values.
        for i in xrange(1000000):
            checku(i)
        for i in xrange(-500000, 500000):
            checks(i)

        # A wider range of valid values.
        for i in xrange(0, 1000000000, 9337):
            checks(i)
        for i in xrange(-500000000, 500000000, 9337):
            checks(i)

        # Get the max/min values.
        ulmax, lmax, lmin = (
            Tf._GetULongMax(), Tf._GetLongMax(), Tf._GetLongMin())

        # Check the extrema and one before to ensure they work.
        map(checku, [ulmax-1, ulmax])
        map(checks, [lmin, lmin+1, lmax-1, lmax])

        # Check that some beyond the extrema over/underflow.
        #
        # Unsigned overflow.
        for i in xrange(1, 1000):
            with self.assertRaises(ValueError):
                checku(ulmax + i)
            with self.assertRaises(ValueError):
                checks(lmax + i)
            with self.assertRaises(ValueError):
                checks(lmin - i)
开发者ID:400dama,项目名称:USD,代码行数:37,代码来源:testTfStringUtils.py

示例9: test_TfPyClassMethod

    def test_TfPyClassMethod(self):
        c = Tf._ClassWithClassMethod()

        # Test classmethod invokation.
        def _TestCallable():
            return 123
        self.assertEqual((Tf._ClassWithClassMethod, 123), c.Test(_TestCallable))

        # Test classmethod error handling.
        class _TestException(Exception):
            '''A sample exception to raise.'''
            pass
        def _TestCallableWithException():
            raise _TestException()

        with self.assertRaises(_TestException):
            c.Test(_TestCallableWithException)
开发者ID:400dama,项目名称:USD,代码行数:17,代码来源:testTfPython.py

示例10: test_Exception

    def test_Exception(self):
        with self.assertRaises(RuntimeError):
            Tf._TakesBase(Raiser())

        with self.assertRaises(Tf.ErrorException) as cm:
            Tf._mightRaise(True)
        for x in cm.exception:
            self.assertTrue(len(repr(x)))

        with self.assertRaises(Tf.ErrorException):
            Tf.RaiseCodingError("some error")

        with self.assertRaises(Tf.ErrorException):
            Tf.RaiseRuntimeError("some error")

        with self.assertRaises(Tf.ErrorException):
            Tf._doErrors()
开发者ID:400dama,项目名称:USD,代码行数:17,代码来源:testTfPython.py

示例11: test_EnumValuesRemovedFromTypeScope

    def test_EnumValuesRemovedFromTypeScope(self):
        with self.assertRaises(AttributeError):
            Tf._takesTestEnum(Tf._TestEnum._Alpha)

        self.assertEqual((Tf._Alpha, Tf._Bravo, Tf._Charlie, Tf._Delta),
                Tf._TestEnum.allValues)

        with self.assertRaises(TypeError):
            Tf._takesTestEnum(Tf._Enum.One)
        with self.assertRaises(TypeError):
            Tf._takesTestEnum2(Tf._Alpha)

        self.assertEqual((Tf._Enum.One, Tf._Enum.Two, Tf._Enum.Three),
                Tf._Enum.TestEnum2.allValues)

        self.assertEqual(1, Tf._Enum.One.value)
        self.assertEqual(2, Tf._Enum.Two.value)
        self.assertEqual(3, Tf._Alpha.value)
        self.assertEqual('A', Tf._Alpha.displayName)
        self.assertEqual('B', Tf._Bravo.displayName)
        self.assertEqual(Tf._Alpha, Tf.Enum.GetValueFromFullName(Tf._Alpha.fullName))
        self.assertEqual(None, Tf.Enum.GetValueFromFullName("invalid_enum_name"))

        self.assertTrue(Tf._Enum.One == 1)
        self.assertTrue(Tf._Enum.Two == 2)
        self.assertTrue(Tf._Alpha == 3)

        self.assertTrue(1 == Tf._Enum.One)
        self.assertTrue(2 == Tf._Enum.Two)
        self.assertTrue(3 == Tf._Alpha)

        self.assertTrue(Tf._Alpha | Tf._Alpha is Tf._Alpha)
        self.assertTrue(Tf._Alpha & Tf._Alpha is Tf._Alpha)
        self.assertTrue(Tf._Alpha == 3)
        self.assertTrue(Tf._Alpha | 1 is Tf._Alpha)
        self.assertTrue(2 | Tf._Alpha is Tf._Alpha)
        self.assertTrue(4 | Tf._Alpha == 7)

        self.assertTrue(Tf._Alpha & 3 is Tf._Alpha)
        self.assertTrue(3 & Tf._Alpha is Tf._Alpha)
        self.assertTrue(2 & Tf._Alpha == 2)

        self.assertTrue(Tf._Enum.One ^ Tf._Enum.Two == 3)
        self.assertTrue(4 ^ Tf._Alpha == 7)
        self.assertTrue(Tf._Alpha ^ 4 == 7)
开发者ID:400dama,项目名称:USD,代码行数:45,代码来源:testTfPython.py

示例12: test_BaseDerived

    def test_BaseDerived(self):
        mb = MyBase()
        d = Tf._TestDerived()
        md = MyDerived()

        self.assertEqual('unwrapped virtual', mb.TestCallVirtual())

        self.assertEqual('cpp base', mb.Virtual4())
        self.assertEqual('python derived v4', md.Virtual4())

        self.assertEqual((False, 'python base'), Tf._TakesBase(mb))
        self.assertEqual((True, 'cpp derived'), Tf._TakesBase(d))
        self.assertEqual((True, 'python derived'), Tf._TakesBase(md))

        self.assertEqual('python base', Tf._TakesConstBase(mb))
        self.assertEqual('cpp derived', Tf._TakesConstBase(d))
        self.assertEqual('python derived', Tf._TakesConstBase(md))

        self.assertEqual('cpp derived', Tf._TakesDerived(d))
        self.assertEqual('python derived', Tf._TakesDerived(md))

        self.assertIs(Tf._ReturnsConstBase(md), md)
        self.assertIs(Tf._ReturnsBase(md), md)
        self.assertIs(Tf._ReturnsBaseRefPtr(md), md)

        try:
            Tf._TestBase().Virtual()
            assert False, 'calling pure virtual'
        except:
            pass
开发者ID:400dama,项目名称:USD,代码行数:30,代码来源:testTfPython.py

示例13: test_TfMakePyConstructorWithVarArgs

    def test_TfMakePyConstructorWithVarArgs(self):
        with self.assertRaises(TypeError):
            Tf._ClassWithVarArgInit()

        def CheckResults(c, allowExtraArgs, args, kwargs):
            self.assertEqual(c.allowExtraArgs, allowExtraArgs)
            self.assertEqual(c.args, args)
            self.assertEqual(c.kwargs, kwargs)

        def StandardTests(allowExtraArgs):
            CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs),
                        allowExtraArgs, (), {})
            CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1),
                        allowExtraArgs, (), {'a':1})
            CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1, 2, 3),
                        allowExtraArgs, (), {'a':1, 'b':2, 'c':3})
            CheckResults(Tf._ClassWithVarArgInit(allowExtraArgs, 1, 2, c=3),
                        allowExtraArgs, (), {'a':1, 'b':2, 'c':3})

        # Tests with extra arguments disallowed.
        StandardTests(allowExtraArgs=False)

        # These cases should emit an error because there are unexpected 
        # arguments
        with self.assertRaises(TypeError):
            Tf._ClassWithVarArgInit(False, 1, 2, 3, 4)

        with self.assertRaises(TypeError):
            Tf._ClassWithVarArgInit(False, d=4)

        # This should emit an error because we have multiple values for a single 
        # arg.
        with self.assertRaises(TypeError):
            Tf._ClassWithVarArgInit(False, 1, 2, 3, b=4)

        # Tests with extra arguments allowed.
        StandardTests(allowExtraArgs=True)

        CheckResults(Tf._ClassWithVarArgInit(True, 1, 2, 3, 4, 5),
                    True, (4,5), {'a':1, 'b':2, 'c':3})
        CheckResults(Tf._ClassWithVarArgInit(True, 1, 2, c=3, d=6, f=8),
                    True, (), {'a':1, 'b':2, 'c':3, 'd':6, 'f':8})
        CheckResults(Tf._ClassWithVarArgInit(True, 1, 2, 3, 4, d=8),
                    True, (4,), {'a':1, 'b':2, 'c':3, 'd':8})
开发者ID:400dama,项目名称:USD,代码行数:44,代码来源:testTfPython.py

示例14: test_TfPyObjWrapper

    def test_TfPyObjWrapper(self):
        self.assertEqual('a', Tf._RoundTripWrapperTest('a'))
        self.assertEqual(1234, Tf._RoundTripWrapperTest(1234))
        self.assertEqual([], Tf._RoundTripWrapperTest([]))
        self.assertEqual(None, Tf._RoundTripWrapperTest(None))

        self.assertEqual('a', Tf._RoundTripWrapperCallTest(lambda: 'a'))
        self.assertEqual(1234, Tf._RoundTripWrapperCallTest(lambda: 1234))
        self.assertEqual([], Tf._RoundTripWrapperCallTest(lambda: []))
        self.assertEqual(None, Tf._RoundTripWrapperCallTest(lambda: None))

        self.assertEqual('a', Tf._RoundTripWrapperIndexTest(['a','b'], 0))
        self.assertEqual('b', Tf._RoundTripWrapperIndexTest(['a','b'], 1))
        self.assertEqual(4, Tf._RoundTripWrapperIndexTest([1,2,3,4], -1))
开发者ID:400dama,项目名称:USD,代码行数:14,代码来源:testTfPython.py

示例15: test_TakeVectorOfVectorOfStrings

 def test_TakeVectorOfVectorOfStrings(self):
     self.assertEqual(4, Tf._TakesVecVecString([['1', '2', '3'], ['4', '5'], [], ['6']]))
开发者ID:400dama,项目名称:USD,代码行数:2,代码来源:testTfPython.py


注:本文中的pxr.Tf类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。