|
1 | 1 | import sys
|
2 | 2 | from pathlib import Path, PurePosixPath
|
3 | 3 | from unittest.mock import ANY, Mock
|
| 4 | +import warnings |
4 | 5 |
|
5 | 6 | import jupytext
|
6 | 7 | import nbconvert
|
@@ -488,36 +489,33 @@ def test_can_execute_when_product_is_metaproduct(tmp_directory):
|
488 | 489 | dag.build()
|
489 | 490 |
|
490 | 491 |
|
491 |
| -# should not have warning when have multiple exports and |
492 |
| -# nbconvert_export_kwargs set |
493 |
| -@pytest.mark.parametrize('product, nb_product_key, nbconvert_exporter_name', [ |
494 |
| - ({ |
495 |
| - 'nb': File(Path('out.pdf')), |
496 |
| - 'file': File(Path('another', 'data', 'file.txt')), |
497 |
| - }, 'nb', 'webpdf') |
498 |
| -]) |
499 |
| -def test_multiple_nb_no_kwargs_warning(product, nb_product_key, |
500 |
| - nbconvert_exporter_name): |
| 492 | +def test_do_not_warn_on_nbconvert_export_kwargs_if_multiple_outputs( |
| 493 | + tmp_directory): |
501 | 494 | dag = DAG()
|
502 | 495 |
|
503 | 496 | code = """
|
504 | 497 | # + tags=["parameters"]
|
505 |
| -var = None |
| 498 | +upstream = None |
506 | 499 |
|
507 | 500 | # +
|
508 |
| -from pathlib import Path |
509 |
| -Path(product['file']).touch() |
| 501 | +1 + 1 |
510 | 502 | """
|
511 | 503 |
|
512 | 504 | NotebookRunner(code,
|
513 |
| - product=product, |
| 505 | + product={ |
| 506 | + 'nb': File('out.ipynb'), |
| 507 | + 'report': File('out.html'), |
| 508 | + }, |
514 | 509 | dag=dag,
|
515 | 510 | ext_in='py',
|
516 |
| - nbconvert_exporter_name=nbconvert_exporter_name, |
517 |
| - nb_product_key=nb_product_key, |
| 511 | + nb_product_key=['nb', 'report'], |
518 | 512 | nbconvert_export_kwargs=dict(exclude_input=True),
|
519 | 513 | name='nb')
|
520 |
| - dag.build() |
| 514 | + |
| 515 | + with warnings.catch_warnings(): |
| 516 | + # fail the test if this displays a warnings |
| 517 | + warnings.simplefilter("error") |
| 518 | + dag.build() |
521 | 519 |
|
522 | 520 |
|
523 | 521 | @pytest.mark.parametrize('product, nb_product_key, nbconvert_exporter_name', [
|
@@ -555,7 +553,7 @@ def test_multiple_nb_no_kwargs_warning(product, nb_product_key,
|
555 | 553 | 'file': File(Path('another', 'data', 'file.txt')),
|
556 | 554 | }, 'nb', 'webpdf')
|
557 | 555 | ])
|
558 |
| -def test_multiple_nb_product_success(product, nb_product_key, |
| 556 | +def test_multiple_nb_product_success(tmp_directory, product, nb_product_key, |
559 | 557 | nbconvert_exporter_name):
|
560 | 558 | dag = DAG()
|
561 | 559 |
|
|
0 commit comments