Skip to content

Commit

Permalink
Check that filename input/output works in x2sys_cross
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jul 23, 2020
1 parent 5e4d419 commit fe528d4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pygmt/tests/test_x2sys_cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fe528d4

Please sign in to comment.