Code Search for Developers
 
 
  

test_privateBinding.py from p4shelf at Krugle


Show test_privateBinding.py syntax highlighted

#####################################################################################
#
#  Copyright (c) Microsoft Corporation. All rights reserved.
#
#  This source code is subject to terms and conditions of the Shared Source License
#  for IronPython. A copy of the license can be found in the License.html file
#  at the root of this distribution. If you can not locate the Shared Source License
#  for IronPython, please send an email to ironpy@microsoft.com.
#  By using this source code in any fashion, you are agreeing to be bound by
#  the terms of the Shared Source License for IronPython.
#
#  You must not remove this notice, or any other, from this software.
#
######################################################################################

##
## Test "-X:PrivateBinding"
##

from lib.assert_util import *
from lib.file_util import *
from lib.process_util import *

import System
privateBinding = "-X:PrivateBinding" in System.Environment.GetCommandLineArgs()

load_iron_python_test()
import IronPythonTest
from IronPythonTest import *

clsPart = ClsPart()

def Negate(i): return -i

def test_Common():
    # !!! AreEqual("InternalClsPart" in dir(IronPythonTest), privateBinding)
    # !!! AreEqual("InternalClsPart" in dir(), privateBinding)
    AreEqual("_ClsPart__privateField" in dir(ClsPart), privateBinding)
    AreEqual("_ClsPart__privateProperty" in dir(ClsPart), privateBinding)
    AreEqual("_ClsPart__privateEvent" in dir(ClsPart), privateBinding)
    AreEqual("_ClsPart__privateMethod" in dir(ClsPart), privateBinding)
    pass

if not privateBinding: 
    def test_NormalBinding():    
        try:
            # no public types in namespace, shouldn't be able to get namespace
            from IronPython.Compiler import Generation
        except ImportError:
            pass

        # mixed namespace
        import IronPython.Runtime
        AssertError(AttributeError, lambda: IronPython.Runtime.TopReflectedPackage)
        
else: 
    def test_PrivateBinding():
        # entirely internal namespace
        from IronPython.Compiler import Generation
        x = Generation.Namespace(None)
        
        # mixed namespace
        import IronPython.Runtime
        x = IronPython.Runtime.TopReflectedPackage
        
        clsPart._ClsPart__privateField = 1
        AreEqual(clsPart._ClsPart__privateField, 1)
        clsPart._ClsPart__privateProperty = 1
        AreEqual(clsPart._ClsPart__privateProperty, 1)
        # !!! clsPart._ClswPart__privateEvent += Negate
        clsPart._ClsPart__privateEvent = Negate
        AreEqual(clsPart._ClsPart__privateMethod(1), -1)
        
        # !!! internalClsPart = InternalClsPart()
        internalClsPart = IronPythonTest.InternalClsPart()
        internalClsPart._InternalClsPart__Field = 1
        AreEqual(internalClsPart._InternalClsPart__Field, 1)
        internalClsPart._InternalClsPart__Property = 1
        AreEqual(internalClsPart._InternalClsPart__Property, 1)
        # !!! internalClsPart._InternalClsPart__Event += Negate
        internalClsPart._InternalClsPart__Event = Negate
        AreEqual(internalClsPart._InternalClsPart__Method(1), -1)
        
        # !!! AreEqual("_InternalClsPart__privateField" in dir(IronPythonTest.InternalClsPart), True)
        # !!! AreEqual("_InternalClsPart__privateProperty" in dir(InternalClsPart), True)
        # !!! AreEqual("_InternalClsPart__privateEvent" in dir(InternalClsPart), True)
        # !!! AreEqual("_InternalClsPart__privateMethod" in dir(InternalClsPart), True)

# use this when running standalone
#run_test(__name__)

run_test(__name__, noOutputPlease=True)

if not privateBinding:
    launch_ironpython_changing_extensions(__file__, add=["-X:PrivateBinding"])



See more files for this project here

p4shelf

A feature in Visual Studio Team Studio that was immediately appealing to me was shelving. The goal of this tool is replicate that general functionality in Perforce.

Project homepage: http://code.google.com/p/p4shelf/
Programming language(s): C#,C++,Python
License: gpl2

  Inc/
  Inputs/
  compat/
  lib/
  c1.cs
  c2.cs
  c3.cs
  categories.py
  custombuiltins.py
  dllsite.py
  iprun.py
  pretest.py
  run.py
  test_array.py
  test_assert.py
  test_attr.py
  test_attrinjector.py
  test_bigint.py
  test_binascii.py
  test_bool.py
  test_buffer.py
  test_builtinfunc.py
  test_cPickle.py
  test_cStringIO.py
  test_class.py
  test_cliclass.py
  test_closure.py
  test_clrexception.py
  test_clrload.py
  test_clrload2.py
  test_clrnuminterop.py
  test_codecs.py
  test_codedom.py
  test_cominterop.py
  test_complex.py
  test_conditional.py
  test_datetime.py
  test_decorator.py
  test_delegate.py
  test_dict.py
  test_dllsite.py
  test_doc.py
  test_event.py
  test_exceptionconverter.py
  test_exceptions.py
  test_exec.py
  test_execfile.py
  test_file.py
  test_formatting.py
  test_function.py
  test_future.py
  test_generator.py
  test_genericmeth.py
  test_help.py
  test_imp.py
  test_importpkg.py
  test_in.py
  test_index.py
  test_inheritance.py
  test_interactive.py
  test_ipyc.py
  test_ipye.py
  test_ironmath.py
  test_isinstance.py
  test_iterator.py
  test_kwarg.py
  test_list.py
  test_listcomp.py
  test_marshal.py
  test_math.py
  test_memory.py
  test_methodbinder1.py
  test_methodbinder2.py
  test_methoddispatch.py
  test_missing.py
  test_namebinding.py
  test_nofuture.py
  test_nonetype.py
  test_nt.py
  test_number.py
  test_numtypes.py
  test_operator.py
  test_privateBinding.py
  test_property.py
  test_protected.py
  test_python25.py
  test_random.py
  test_re.py
  test_set.py
  test_slice.py
  test_socket.py
  test_specialcontext.py
  test_statics.py
  test_stdconsole.py
  test_str.py
  test_struct.py
  test_superconsole.py
  test_syntax.py
  test_sys.py
  test_thread.py