def test_extraction(self): py_modules = [('tf', tf), ('tfdbg', tf_debug)] try: generate_lib.extract( py_modules, generate_lib._get_default_private_map(), generate_lib._get_default_do_not_descend_map()) except RuntimeError: print( '*****************************************************************' ) print( 'If this test fails, you have most likely introduced an unsealed' ) print( 'module. Make sure to use remove_undocumented or similar utilities' ) print( 'to avoid leaking symbols. See below for more information on the' ) print('failure.') print( '*****************************************************************' ) raise
def test_extraction(self): modules = [('tf', tf), ('tfdbg', tf_debug)] _ = tf.contrib.__name__ # Trigger loading of tf.contrib try: generate_lib.extract(modules) except RuntimeError: print('*****************************************************************') print('If this test fails, you have most likely introduced an unsealed') print('module. Make sure to use remove_undocumented or similar utilities') print('to avoid leaking symbols. See below for more information on the') print('failure.') print('*****************************************************************') raise
def test_extraction(self): py_modules = [('tf', tf), ('tfdbg', tf_debug)] try: generate_lib.extract( py_modules, generate_lib._get_default_do_not_descend_map()) except RuntimeError: print('*****************************************************************') print('If this test fails, you have most likely introduced an unsealed') print('module. Make sure to use remove_undocumented or similar utilities') print('to avoid leaking symbols. See below for more information on the') print('failure.') print('*****************************************************************') raise
def test_duplicates_module_depth(self): class Parent(object): pass tf = types.ModuleType('tf') tf.submodule = types.ModuleType('submodule') tf.submodule.submodule2 = types.ModuleType('submodule2') tf.Parent = Parent tf.submodule.submodule2.Parent = Parent visitor = generate_lib.extract([('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual( { 'tf.Parent': sorted(['tf.Parent', 'tf.submodule.submodule2.Parent']), }, visitor.duplicates) self.assertEqual({'tf.submodule.submodule2.Parent': 'tf.Parent'}, visitor.duplicate_of) self.assertEqual( { id(tf): 'tf', id(tf.submodule): 'tf.submodule', id(tf.submodule.submodule2): 'tf.submodule.submodule2', id(Parent): 'tf.Parent', }, visitor.reverse_index)
def test_duplicates_defining_class(self): class Parent(object): obj1 = object() class Child(Parent): pass tf = types.ModuleType('tf') tf.Parent = Parent tf.Child = Child visitor = generate_lib.extract([('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual( { 'tf.Parent.obj1': sorted([ 'tf.Parent.obj1', 'tf.Child.obj1', ]), }, visitor.duplicates) self.assertEqual({ 'tf.Child.obj1': 'tf.Parent.obj1', }, visitor.duplicate_of) self.assertEqual( { id(tf): 'tf', id(Parent): 'tf.Parent', id(Child): 'tf.Child', id(Parent.obj1): 'tf.Parent.obj1', }, visitor.reverse_index)
def test_duplicates_name(self): class Parent(object): obj1 = object() Parent.obj2 = Parent.obj1 tf = types.ModuleType('tf') tf.submodule = types.ModuleType('submodule') tf.submodule.Parent = Parent visitor = generate_lib.extract( [('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual({ 'tf.submodule.Parent.obj1': sorted([ 'tf.submodule.Parent.obj1', 'tf.submodule.Parent.obj2', ]), }, visitor.duplicates) self.assertEqual({ 'tf.submodule.Parent.obj2': 'tf.submodule.Parent.obj1', }, visitor.duplicate_of) self.assertEqual({ id(tf): 'tf', id(tf.submodule): 'tf.submodule', id(Parent): 'tf.submodule.Parent', id(Parent.obj1): 'tf.submodule.Parent.obj1', }, visitor.reverse_index)
def test_duplicates_module_depth(self): class Parent(object): pass tf = types.ModuleType('tf') tf.submodule = types.ModuleType('submodule') tf.submodule.submodule2 = types.ModuleType('submodule2') tf.Parent = Parent tf.submodule.submodule2.Parent = Parent visitor = generate_lib.extract( [('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual({ 'tf.Parent': sorted(['tf.Parent', 'tf.submodule.submodule2.Parent']), }, visitor.duplicates) self.assertEqual({ 'tf.submodule.submodule2.Parent': 'tf.Parent' }, visitor.duplicate_of) self.assertEqual({ id(tf): 'tf', id(tf.submodule): 'tf.submodule', id(tf.submodule.submodule2): 'tf.submodule.submodule2', id(Parent): 'tf.Parent', }, visitor.reverse_index)
def test_duplicates_defining_class(self): class Parent(object): obj1 = object() class Child(Parent): pass tf = types.ModuleType('tf') tf.Parent = Parent tf.Child = Child visitor = generate_lib.extract( [('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual({ 'tf.Parent.obj1': sorted([ 'tf.Parent.obj1', 'tf.Child.obj1', ]), }, visitor.duplicates) self.assertEqual({ 'tf.Child.obj1': 'tf.Parent.obj1', }, visitor.duplicate_of) self.assertEqual({ id(tf): 'tf', id(Parent): 'tf.Parent', id(Child): 'tf.Child', id(Parent.obj1): 'tf.Parent.obj1', }, visitor.reverse_index)
def test_extraction(self): modules = [('tf', tf), ('tfdbg', tf_debug)] _ = tf.contrib.__name__ # Trigger loading of tf.contrib try: generate_lib.extract(modules) except RuntimeError: print( '*****************************************************************' ) print( 'If this test fails, you have most likely introduced an unsealed' ) print( 'module. Make sure to use remove_undocumented or similar utilities' ) print( 'to avoid leaking symbols. See below for more information on the' ) print('failure.') print( '*****************************************************************' ) raise
def test_duplicates_name(self): class Parent(object): obj1 = object() Parent.obj2 = Parent.obj1 tf = types.ModuleType('tf') tf.submodule = types.ModuleType('submodule') tf.submodule.Parent = Parent visitor = generate_lib.extract([('tf', tf)], private_map={}, do_not_descend_map={}, visitor_cls=NoDunderVisitor) self.assertEqual( { 'tf.submodule.Parent.obj1': sorted([ 'tf.submodule.Parent.obj1', 'tf.submodule.Parent.obj2', ]), }, visitor.duplicates) self.assertEqual( { 'tf.submodule.Parent.obj2': 'tf.submodule.Parent.obj1', }, visitor.duplicate_of) self.assertEqual( { id(tf): 'tf', id(tf.submodule): 'tf.submodule', id(Parent): 'tf.submodule.Parent', id(Parent.obj1): 'tf.submodule.Parent.obj1', }, visitor.reverse_index)