File: test_import_fail.py

package info (click to toggle)
python-parsl 2025.01.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,072 kB
  • sloc: python: 23,817; makefile: 349; sh: 276; ansic: 45
file content (41 lines) | stat: -rw-r--r-- 691 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import parsl
from parsl.app.app import python_app


@python_app
def platform_name():
    return platform.platform()


def test_name_error(n=2):
    """Catch NameError for missing name
    """

    p = platform_name()

    try:
        p.result()
    except NameError:
        print("Caught NameError")
    else:
        assert False, "Raise the wrong Error"


@python_app
def bad_import():
    import non_existent
    return non_existent.foo()


def test_import_error(n=2):
    """Catch ImportError for missing name
    """

    p = bad_import()

    try:
        p.result()
    except ImportError:
        print("Caught ImportError")
    else:
        assert False, "Raise the wrong Error"