Exemplo n.º 1
0
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",
        ])
Exemplo n.º 2
0
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
Exemplo n.º 3
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
Exemplo n.º 4
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")
Exemplo n.º 5
0
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
Exemplo n.º 6
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"
Exemplo n.º 7
0
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
Exemplo n.º 8
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
Exemplo n.º 9
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"]
Exemplo n.º 10
0
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"
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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"])
Exemplo n.º 13
0
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
Exemplo n.º 14
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 == ""
Exemplo n.º 15
0
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")])
Exemplo n.º 16
0
from nonos.main import main

if __name__ == "__main__":
    exit(main())