Compare two methods by their source code.
(method1, method2)
| 233 | |
| 234 | |
| 235 | def is_same_method(method1, method2): |
| 236 | """Compare two methods by their source code.""" |
| 237 | try: |
| 238 | source1 = get_method_source(method1) |
| 239 | source2 = get_method_source(method2) |
| 240 | |
| 241 | # Remove method decorators if any |
| 242 | source1 = "\n".join(line for line in source1.split("\n") if not line.strip().startswith("@")) |
| 243 | source2 = "\n".join(line for line in source2.split("\n") if not line.strip().startswith("@")) |
| 244 | |
| 245 | return source1 == source2 |
| 246 | except (TypeError, OSError): |
| 247 | return False |
| 248 | |
| 249 | |
| 250 | def is_same_item(item1, item2): |
no test coverage detected