File: test_6.py

package info (click to toggle)
mpi4py 4.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,544 kB
  • sloc: python: 34,453; ansic: 16,475; makefile: 614; sh: 325; cpp: 193; f90: 178
file content (20 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from importlib import import_module
from os import environ
from warnings import catch_warnings

from mpi4py import rc

ATTRS = {a for a in dir(rc) if not a.startswith("_")}
VALUE = -123456789

for attr in ATTRS:
    environ.pop(f"MPI4PY_RC_{attr.upper()}", None)
    setattr(rc, attr, VALUE)

with catch_warnings(record=True) as warnings:
    import_module("mpi4py.MPI")

template = "mpi4py.rc.{}: unexpected value {}"
expected = sorted({template.format(attr, repr(VALUE)) for attr in ATTRS})
messages = sorted({str(entry.message) for entry in warnings})
assert messages == expected, "\n" + "\n".join(messages)