def test_error_no_planet(test_data_dir, tmp_path): os.chdir(tmp_path) # just check that the call returns the correct err with pytest.raises(FileNotFoundError, match=r"planet0\.dat not found"): main([ "-cor", "0", "-dir", str(test_data_dir / "idefix_rwi"), "-geometry", "polar", ])
def test_pbar(simulation_dir, capsys): ret = main(["-pbar", "-dir", str(simulation_dir), "-geometry", "polar"]) out, err = capsys.readouterr() assert err == "" assert "Processing snapshots" in out assert ret == 0
def test_verbose_debug(simulation_dir, capsys): ret = main(["-vv", "-dir", str(simulation_dir), "-geometry", "polar"]) out, err = capsys.readouterr() assert err == "" assert "DEBUG" in out assert ret == 0
def test_no_inifile(capsys, tmp_path): os.chdir(tmp_path) ret = main([]) assert ret != 0 out, err = capsys.readouterr() assert out == "" assert err.endswith("idefix.ini, pluto.ini, variables.par not found.\n")
def test_verbose_info(simulation_dir, capsys): ret = main(["-v", "-dir", str(simulation_dir), "-geometry", "polar"]) out, err = capsys.readouterr() assert err == "" assert "Operation took" in out assert "INFO" in out assert ret == 0
def test_version(capsys, tmp_path): os.chdir(tmp_path) ret = main(["-version"]) assert ret == 0 out, err = capsys.readouterr() assert err == "" assert out == str(__version__) + "\n"
def test_newvtk_geometry(test_data_dir, capsys, tmp_path): os.chdir(tmp_path) ret = main( ["-cor", "0", "-dir", str(test_data_dir / "idefix_newvtk_planet2d")]) out, err = capsys.readouterr() assert out == "" assert err == "" assert ret == 0
def test_plot_simple(argv, simulation_dir, capsys, tmp_path): os.chdir(tmp_path) ret = main(argv + ["-dir", str(simulation_dir), "-geometry", "polar"]) out, err = capsys.readouterr() assert err == "" assert out == "" assert ret == 0 assert len(glob("*.png")) > 0
def test_isolated_mode(minimal_paramfile, capsys): os.chdir(minimal_paramfile.parent) ret = main(["-config", "-isolated"]) assert ret == 0 out, err = capsys.readouterr() assert err == "" conf = inifix.loads(out) assert conf["field"] == DEFAULTS["field"]
def test_load_config_file(minimal_paramfile, capsys): os.chdir(minimal_paramfile.parent) ret = main(["-input", "nonos.ini", "-config"]) assert ret == 0 out, err = capsys.readouterr() assert "Using parameters from" in err conf = inifix.loads(out) assert conf["field"] == "VX1"
def test_common_image_formats(format, simulation_dir, capsys, tmp_path): os.chdir(tmp_path) ret = main( ["-dir", str(simulation_dir), "-fmt", format, "-geometry", "polar"]) out, err = capsys.readouterr() assert err == "" assert out == "" assert ret == 0 assert len(glob(f"*.{format}")) == 1
def test_default_conf(capsys, tmp_path): os.chdir(tmp_path) ret = main(["-config"]) assert ret == 0 out, err = capsys.readouterr() assert err == "" # validate output is reusable (tmp_path / "idefix.ini").touch() dictout = inifix.loads(out) Parameters(directory=dictout["datadir"])
def test_plot_simple_corotation(planet_simulation_dir, capsys, tmp_path): os.chdir(tmp_path) # just check that the call returns no err ret = main([ "-cor", "0", "-dir", str(planet_simulation_dir), "-geometry", "polar" ]) out, err = capsys.readouterr() assert out == "" assert err == "" assert ret == 0
def test_logo(capsys, tmp_path): os.chdir(tmp_path) ret = main(["-logo"]) assert ret == 0 out, err = capsys.readouterr() expected = textwrap.dedent(r""" `!)}$$$$})!` `,!>|))|!, :}&#&$}{{}$&#&};` ~)$&&$$}}$$&#$). '}#&}|~'.```.'!($#$+ `=$&$(^,..``.'~=$&&= `|&#}!'` `'?$#}. !$&}:.` `.!$#$' :$#$^'` `` .$#$` ^&&+. `'(&$! `)&&),` !##! `$#^ `. ` `={$&{` ^$&$(!' `` `,. `` !##! ,#$ `` .>}&${?!:'` ```..'',:!+|{$&${:` `'` `}&}` `$$` ,;|{}$$$&&&&&$$$$}}()<!,` '` `}&}` +&}` ` |:|.\ |:| `.``` :$$! !$$'`!}| |:|\.\ |:| __ __ ___ .{#$ '$&})$: |:| \.\ |:| /./ \.\ |:|.\ |:| /./ \.\ |:| \.\ '$$#} `}#&; |:| \.\ |:| |:| |:| |:|\.\ |:| |:| |:| |:|___ :$)&$` `{&! |:| \.\|:| |:| |:| |:| \.\|:| |:| |:| |:| :!{&}` :$$, |:| \.|:| \.\__/./ |:| \.|:| \.\__/./ \.\__|:| `:}#}` ^&$. .$#^ +&$. ``'^)}$$$$$({}}}$$$$$$$$$$}}(|>!.`~:,. }#) '&#| ,|$##$>'` `'~!)$##$$$)?^,` ` :&&: ,&#}` `` .` `:{$&}: ~}&$)^^+=^` `` .. .|&#) |&#$:``` `` '::!}$&}, !$&$|++^^:,:~',!!($#&^ ,}&#${^~,,,:!|}$&&(. ^$#$}{)|?|)(}$&#$?` :{&##$$$$$&##$). ~($&#&&##&$}=, `:|}$$$$}):` Analysis tool for idefix/pluto/fargo3d simulations (in polar coordinates). """.lstrip("\n")) expected += f"Version {__version__}\n" assert out == expected assert err == ""
def test_unknown_geometry(test_data_dir, tmp_path): os.chdir(tmp_path) with pytest.raises(RuntimeError, match=r"Geometry couldn't be determined from data"): main(["-dir", str(test_data_dir / "idefix_rwi")])
from nonos.main import main if __name__ == "__main__": exit(main())