()
| 631 | |
| 632 | |
| 633 | def test_assert_eq_scheduler(): |
| 634 | using_custom_scheduler = False |
| 635 | |
| 636 | def custom_scheduler(*args, **kwargs): |
| 637 | nonlocal using_custom_scheduler |
| 638 | try: |
| 639 | using_custom_scheduler = True |
| 640 | return get_sync(*args, **kwargs) |
| 641 | finally: |
| 642 | using_custom_scheduler = False |
| 643 | |
| 644 | def check_custom_scheduler(part: pd.DataFrame) -> pd.DataFrame: |
| 645 | assert using_custom_scheduler, "not using custom scheduler" |
| 646 | return part + 1 |
| 647 | |
| 648 | df = pd.DataFrame({"x": [1, 2, 3, 4]}) |
| 649 | ddf = dd.from_pandas(df, npartitions=2) |
| 650 | ddf2 = ddf.map_partitions(check_custom_scheduler, meta=ddf) |
| 651 | |
| 652 | with pytest.raises(AssertionError, match="not using custom scheduler"): |
| 653 | # NOTE: we compare `ddf2` to itself in order to test both sides of the `assert_eq` logic. |
| 654 | assert_eq(ddf2, ddf2) |
| 655 | |
| 656 | assert_eq(ddf2, ddf2, scheduler=custom_scheduler) |
| 657 | with dask.config.set(scheduler=custom_scheduler): |
| 658 | assert_eq(ddf2, ddf2, scheduler=None) |
| 659 | |
| 660 | |
| 661 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected