Compare method signatures between sync and async versions.
()
| 122 | |
| 123 | |
| 124 | def test_method_signature_comparison(): |
| 125 | """Compare method signatures between sync and async versions.""" |
| 126 | sync_client = DstackClient(TEST_ENDPOINT) |
| 127 | async_client = AsyncDstackClient(TEST_ENDPOINT) |
| 128 | |
| 129 | methods_to_check = [ |
| 130 | "get_key", |
| 131 | "get_quote", |
| 132 | "get_tls_key", |
| 133 | "info", |
| 134 | "emit_event", |
| 135 | "is_reachable", |
| 136 | ] |
| 137 | |
| 138 | for method_name in methods_to_check: |
| 139 | sync_method = getattr(sync_client, method_name) |
| 140 | async_method = getattr(async_client, method_name) |
| 141 | |
| 142 | sync_sig = inspect.signature(sync_method) |
| 143 | async_sig = inspect.signature(async_method) |
| 144 | |
| 145 | print(f"\n{method_name}:") |
| 146 | print(f" Sync signature: {sync_sig}") |
| 147 | print(f" Async signature: {async_sig}") |
| 148 | |
| 149 | # Parameters should be the same (excluding 'self') |
| 150 | sync_params = list(sync_sig.parameters.keys()) |
| 151 | async_params = list(async_sig.parameters.keys()) |
| 152 | |
| 153 | if "self" in sync_params: |
| 154 | sync_params.remove("self") |
| 155 | if "self" in async_params: |
| 156 | async_params.remove("self") |
| 157 | |
| 158 | assert sync_params == async_params, ( |
| 159 | f"Parameter mismatch for {method_name}: sync={sync_params}, async={async_params}" |
| 160 | ) |
| 161 | |
| 162 | |
| 163 | if __name__ == "__main__": |
no test coverage detected