• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

quaquel / EMAworkbench / 18273916295

06 Oct 2025 07:53AM UTC coverage: 88.699% (+0.04%) from 88.664%
18273916295

Pull #422

github

web-flow
Merge 93421bb36 into 592d0cd98
Pull Request #422: ruff fixes

65 of 85 new or added lines in 22 files covered. (76.47%)

2 existing lines in 2 files now uncovered.

7849 of 8849 relevant lines covered (88.7%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

23.26
/ema_workbench/examples/test_examples.py
1
"""Runs all examples."""
2

3
import glob
1✔
4
import os
1✔
5
import sys
1✔
6
import traceback
1✔
7
from contextlib import contextmanager
1✔
8

9
set_backend = "import matplotlib\nmatplotlib.use('Agg')\n"
1✔
10

11

12
@contextmanager
1✔
13
def redirected_output(new_stdout=None, new_stderr=None):
1✔
14
    """Redirects standard output and standard error to stdout."""
15
    save_stdout = sys.stdout
×
16
    save_stderr = sys.stderr
×
17
    if new_stdout is not None:
×
18
        sys.stdout = new_stdout
×
19
    if new_stderr is not None:
×
20
        sys.stderr = new_stderr
×
21
    try:
×
22
        yield None
×
23
    finally:
24
        sys.stdout = save_stdout
×
25
        sys.stderr = save_stderr
×
26

27

28
def run_exectests(test_dir, log_path="exectests.log"):
1✔
29
    """Run all examples."""
30
    test_files = glob.glob(os.path.join(test_dir, "*.py"))
×
31
    test_files = sorted(ex for ex in test_files if ex[0] != "_")
×
32
    passed = []
×
33
    failed = []
×
NEW
34
    with open(log_path, "w") as f, redirected_output(new_stdout=f, new_stderr=f):
×
NEW
35
        for fname in test_files:
×
NEW
36
            print(f">> Executing '{fname}'")
×
NEW
37
            try:
×
NEW
38
                code = compile(
×
39
                    set_backend + open(fname).read(), fname, "exec"
40
                )  # noqa: SIM115
NEW
41
                exec(code, {"__name__": "__main__"}, {})  # noqa: S102
×
NEW
42
                passed.append(fname)
×
NEW
43
            except BaseException:
×
NEW
44
                traceback.print_exc()
×
NEW
45
                failed.append(fname)
×
46

47
    print(f">> Passed {len(passed)}/{len(test_files)} tests: ")
×
48
    print("Passed: " + ", ".join(passed))
×
49
    print("Failed: " + ", ".join(failed))
×
50
    print(f"See {log_path} for details")
×
51

52
    return passed, failed
×
53

54

55
if __name__ == "__main__":
1✔
56
    # fixme: do we want to keep doing this and in this way?
57

58
    try:
×
59
        run_exectests(*sys.argv[1:])
×
60
    except BaseException:
×
61
        run_exectests(os.getcwd())
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc