def test_code_to_file(self): try: code = modulegraph._code_to_file.__code__ except AttributeError: code = modulegraph._code_to_file.func_code data = modulegraph._code_to_file(code) self.assertTrue(hasattr(data, 'read')) content = data.read() self.assertIsInstance(content, bytes) data.close()