def test_main_stdlib_module(): """ This test makes sure that the module is really searched within the sunpy package. """ with pytest.raises(ValueError): sunpy.self_test(package='random')
def test_main_stdlib_module(): """This test makes sure that the module is really searched within the sunpy package. """ with pytest.raises(ValueError): sunpy.self_test(package='random')
def test_main_include_remote_data(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(package='map', online=True) assert args in ([ os.path.join('sunpy', 'map'), '--remote-data=any', '-m', 'not figure' ], [ os.path.join(root_dir, 'map'), '--remote-data=any', '-m', 'not figure' ])
def test_main_coverage(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(coverage=True) for a in args: assert a in [root_dir, 'sunpy', '--cov', '--cov-config', '-m', 'not figure', os.path.join(root_dir, 'tests', 'coveragerc'), os.path.join('sunpy', 'tests', 'coveragerc')]
def test_main_coverage_report_html(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(coverage=True, cov_report=True) for a in args: assert a in [ root_dir, 'sunpy', '--cov', '--cov-config', '-m', 'not figure', os.path.join(root_dir, 'tests', 'coveragerc'), os.path.join('sunpy', 'tests', 'coveragerc'), '--cov-report' ]
def test_main_submodule_jsoc(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(package='net.jsoc') assert args in ([ os.path.join('sunpy', 'net', 'jsoc'), '-m', 'not figure' ], [os.path.join(root_dir, 'net', 'jsoc'), '-m', 'not figure'])
def test_main_noargs(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test() assert args in (['sunpy', '-m', 'not figure'], [root_dir, '-m', 'not figure'])
def test_main_nonexisting_module(): with pytest.raises(ValueError): sunpy.self_test(package='doesnotexist')
def test_main_figures(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(figure=True) assert args in (['sunpy'], [root_dir])
def test_main_only_remote_data(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(package='map', online_only=True) assert args in ([os.path.join('sunpy', 'map'), '-k remote_data', '--remote-data=any', '-m', 'not figure'], [os.path.join(root_dir, 'map'), '-k remote_data', '--remote-data=any', '-m', 'not figure'])
def test_main_exclude_remote_data(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(package='map', online=False) assert args in ([os.path.join('sunpy', 'map'), '-m', 'not figure'], [os.path.join(root_dir, 'map'), '-m', 'not figure'])
def test_main_submodule_jsoc(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(package='net.jsoc') assert args in ([os.path.join('sunpy', 'net', 'jsoc'), '-m', 'not figure'], [os.path.join(root_dir, 'net', 'jsoc'), '-m', 'not figure'])
def test_main_figure_dir(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(figure_only=True, figure_dir=".") assert args in (['sunpy', '--figure_dir', '.', '-m', 'figure'], [root_dir, '--figure_dir', '.', '-m', 'figure'])
def test_main_figure_only(monkeypatch): monkeypatch.setattr(pytest, 'main', lambda args, **kwargs: args) args = sunpy.self_test(figure_only=True) assert args in (['sunpy', '-m', 'figure'], [root_dir, '-m', 'figure'])
import os import sys # Force OpenBLAS to use a single thread to prevent image-rotation # test failures on macOS. See https://github.com/sunpy/sunpy/issues/4290 # for more information. os.environ['OMP_NUM_THREADS'] = '1' import sunpy sys.exit(sunpy.self_test())