def test_psconvert_without_prefix(): """ Call psconvert without the 'prefix' option. """ fig = Figure() with pytest.raises(GMTInvalidInput): fig.psconvert(fmt="g")
def test_figure_icc_gray(): """ Check if icc_gray parameter works correctly if used. """ fig = Figure() fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) with pytest.warns(expected_warning=FutureWarning) as record: fig.psconvert(icc_gray=True, prefix="Test") assert len(record) == 1 # check that only one warning was raised
def test_psconvert_int_options(): """ psconvert handles integer options well. """ fig = Figure() fig.basemap(R="10/70/-3/8", J="X4i/3i", B="a") prefix = "test_psconvert_int_options" fig.psconvert(F=prefix, E=100, T="g", I=True) assert os.path.exists(prefix + ".png") os.remove(prefix + ".png")
def test_psconvert(): """ psconvert creates a figure in the current directory. """ fig = Figure() fig.basemap(region="10/70/-3/8", projection="X4i/3i", frame="a") prefix = "test_psconvert" fig.psconvert(prefix=prefix, fmt="f", crop=True) fname = prefix + ".pdf" assert os.path.exists(fname) os.remove(fname)
def test_psconvert(): """ psconvert creates a figure in the current directory. """ fig = Figure() fig.basemap(R="10/70/-3/8", J="X4i/3i", B="a") prefix = "test_psconvert" fig.psconvert(F=prefix, T="f", A=True) fname = prefix + ".pdf" assert os.path.exists(fname) os.remove(fname)
def test_psconvert_aliases(): """ Use the aliases to make sure they work. """ fig = Figure() fig.basemap(R="10/70/-3/8", J="X4i/3i", B="a") prefix = "test_psconvert_aliases" fig.psconvert(prefix=prefix, fmt="g", crop=True, dpi=100) fname = prefix + ".png" assert os.path.exists(fname) os.remove(fname)
def test_psconvert_twice(): """ Call psconvert twice to get two figures. """ fig = Figure() fig.basemap(region="10/70/-3/8", projection="X4i/3i", frame="a") prefix = "test_psconvert_twice" # Make a PDF fig.psconvert(prefix=prefix, fmt="f") fname = prefix + ".pdf" assert os.path.exists(fname) os.remove(fname) # Make a PNG fig.psconvert(prefix=prefix, fmt="g") fname = prefix + ".png" assert os.path.exists(fname) os.remove(fname)
def test_figure_savefig(): """ Check if the arguments being passed to psconvert are correct. """ kwargs_saved = [] def mock_psconvert(*args, **kwargs): # pylint: disable=unused-argument """ Just record the arguments. """ kwargs_saved.append(kwargs) fig = Figure() fig.psconvert = mock_psconvert prefix = "test_figure_savefig" fname = ".".join([prefix, "png"]) fig.savefig(fname) assert kwargs_saved[-1] == dict(prefix=prefix, fmt="g", crop=True, Qt=2, Qg=2) fname = ".".join([prefix, "pdf"]) fig.savefig(fname) assert kwargs_saved[-1] == dict(prefix=prefix, fmt="f", crop=True, Qt=2, Qg=2) fname = ".".join([prefix, "png"]) fig.savefig(fname, transparent=True) assert kwargs_saved[-1] == dict(prefix=prefix, fmt="G", crop=True, Qt=2, Qg=2) fname = ".".join([prefix, "eps"]) fig.savefig(fname) assert kwargs_saved[-1] == dict(prefix=prefix, fmt="e", crop=True, Qt=2, Qg=2) fname = ".".join([prefix, "kml"]) fig.savefig(fname) assert kwargs_saved[-1] == dict(prefix=prefix, fmt="g", crop=True, Qt=2, Qg=2, W="+k")