run the matplotlib test suite
(verbosity=None, coverage=False, switch_backend_warn=True,
recursionlimit=0, **kwargs)
| 1497 | |
| 1498 | |
| 1499 | def test(verbosity=None, coverage=False, switch_backend_warn=True, |
| 1500 | recursionlimit=0, **kwargs): |
| 1501 | """run the matplotlib test suite""" |
| 1502 | _init_tests() |
| 1503 | if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')): |
| 1504 | raise ImportError("Matplotlib test data is not installed") |
| 1505 | |
| 1506 | old_backend = get_backend() |
| 1507 | old_recursionlimit = sys.getrecursionlimit() |
| 1508 | try: |
| 1509 | use('agg') |
| 1510 | if recursionlimit: |
| 1511 | sys.setrecursionlimit(recursionlimit) |
| 1512 | import pytest |
| 1513 | |
| 1514 | args = kwargs.pop('argv', []) |
| 1515 | provide_default_modules = True |
| 1516 | use_pyargs = True |
| 1517 | for arg in args: |
| 1518 | if any(arg.startswith(module_path) |
| 1519 | for module_path in default_test_modules): |
| 1520 | provide_default_modules = False |
| 1521 | break |
| 1522 | if os.path.exists(arg): |
| 1523 | provide_default_modules = False |
| 1524 | use_pyargs = False |
| 1525 | break |
| 1526 | if use_pyargs: |
| 1527 | args += ['--pyargs'] |
| 1528 | if provide_default_modules: |
| 1529 | args += default_test_modules |
| 1530 | |
| 1531 | if coverage: |
| 1532 | args += ['--cov'] |
| 1533 | |
| 1534 | if verbosity: |
| 1535 | args += ['-' + 'v' * verbosity] |
| 1536 | |
| 1537 | retcode = pytest.main(args, **kwargs) |
| 1538 | finally: |
| 1539 | if old_backend.lower() != 'agg': |
| 1540 | use(old_backend, warn=switch_backend_warn) |
| 1541 | if recursionlimit: |
| 1542 | sys.setrecursionlimit(old_recursionlimit) |
| 1543 | |
| 1544 | return retcode |
| 1545 | |
| 1546 | |
| 1547 | test.__test__ = False # pytest: this function is not a test |
nothing calls this directly
no test coverage detected