diff --git a/pygmt/tests/test_x2sys_cross.py b/pygmt/tests/test_x2sys_cross.py index 19185f32c3e..3426d6395d5 100644 --- a/pygmt/tests/test_x2sys_cross.py +++ b/pygmt/tests/test_x2sys_cross.py @@ -22,9 +22,31 @@ def fixture_mock_x2sys_home(monkeypatch): monkeypatch.setenv("X2SYS_HOME", os.getcwd()) -def test_x2sys_cross_input_file(mock_x2sys_home): # pylint: disable=unused-argument +def test_x2sys_cross_input_file_output_file( + mock_x2sys_home, +): # pylint: disable=unused-argument """ - Run x2sys_cross by passing in a filename + Run x2sys_cross by passing in a filename and output to an ASCII txt file + """ + fname = which("@tut_ship.xyz", download="a") + with TemporaryDirectory(prefix="X2SYS", dir=os.getcwd()) as tmpdir: + tag = os.path.basename(tmpdir) + x2sys_init(tag=tag, fmtfile="xyz", force=True) + outfile = os.path.join(tmpdir, "tmp_coe.txt") + output = x2sys_cross(tracks=[fname], tag=tag, coe="i", outfile=outfile) + + assert output is None # check that output is None since outfile is set + assert os.path.exists(path=outfile) # check that outfile exists at path + _ = pd.read_csv(outfile, sep="\t", header=2) # ensure ASCII text file loads ok + + return output + + +def test_x2sys_cross_input_file_output_dataframe( + mock_x2sys_home, +): # pylint: disable=unused-argument + """ + Run x2sys_cross by passing in a filename and output to a pandas.DataFrame """ fname = which("@tut_ship.xyz", download="a") with TemporaryDirectory(prefix="X2SYS", dir=os.getcwd()) as tmpdir: