def test_imported_load_method(self):
    sources = ['            import os\n            def foo():\n                return os.uname()\n            ', '            import os as operating_system\n            def foo():\n                return operating_system.uname()\n            ', '            from os import path\n            def foo(x):\n                return path.join(x)\n            ', '            from os import path as os_path\n            def foo(x):\n                return os_path.join(x)\n            ']
    for source in sources:
        namespace = {}
        exec(textwrap.dedent(source), namespace)
        func = namespace['foo']
        with self.subTest(func=func.__name__):
            opcodes = list(dis.get_instructions(func))
            instructions = [opcode.opname for opcode in opcodes]
            self.assertNotIn('LOAD_METHOD', instructions)
            self.assertIn('LOAD_ATTR', instructions)
            self.assertIn('PRECALL', instructions)
def test_imported_load_method(self):
    sources = ['            import os\n            def foo():\n                return os.uname()\n            ', '            import os as operating_system\n            def foo():\n                return operating_system.uname()\n            ', '            from os import path\n            def foo(x):\n                return path.join(x)\n            ', '            from os import path as os_path\n            def foo(x):\n                return os_path.join(x)\n            ']
    for source in sources:
        namespace = {}
        exec(textwrap.dedent(source), namespace)
        func = namespace['foo']
        with self.subTest(func=func.__name__):
            opcodes = list(dis.get_instructions(func))
            instructions = [opcode.opname for opcode in opcodes]
            self.assertNotIn('LOAD_METHOD', instructions)
            self.assertIn('LOAD_ATTR', instructions)
            self.assertIn('PRECALL', instructions)