| 443 | |
| 444 | @wraps(f) |
| 445 | def wrap(*args, **kwargs): |
| 446 | self.init() |
| 447 | # Always raise SkipTest if we can't connect to MongoDB |
| 448 | if not self.connected: |
| 449 | pair = self.pair |
| 450 | raise SkipTest(f"Cannot connect to MongoDB on {pair}") |
| 451 | if iscoroutinefunction(condition): |
| 452 | if condition(): |
| 453 | if wraps_async: |
| 454 | return f(*args, **kwargs) |
| 455 | else: |
| 456 | return f(*args, **kwargs) |
| 457 | elif condition(): |
| 458 | if wraps_async: |
| 459 | return f(*args, **kwargs) |
| 460 | else: |
| 461 | return f(*args, **kwargs) |
| 462 | if "self.pair" in msg: |
| 463 | new_msg = msg.replace("self.pair", self.pair) |
| 464 | else: |
| 465 | new_msg = msg |
| 466 | raise SkipTest(new_msg) |
| 467 | |
| 468 | return wrap |
| 469 | |