test_command_support.py
: Catch warnings
This commit is contained in:
parent
1faaab9e9c
commit
25e6d6f4d4
@ -25,19 +25,21 @@ def convert(path_test, path_tja_tmp, entry_point, err_msg=None):
|
||||
if not err_msg:
|
||||
api_convert(argv=[path_tja_tmp])
|
||||
else:
|
||||
with pytest.raises(Exception) as e:
|
||||
try:
|
||||
api_convert(argv=[path_tja_tmp])
|
||||
tb = "".join(traceback.format_tb(e.tb))
|
||||
except Exception as e:
|
||||
tb = str(e)
|
||||
|
||||
elif entry_point == "python-cli":
|
||||
if not err_msg:
|
||||
subprocess.check_output(f"tja2fumen {path_tja_tmp}", text=True,
|
||||
shell=True, stderr=subprocess.STDOUT)
|
||||
else:
|
||||
with pytest.raises(CalledProcessError) as e:
|
||||
try:
|
||||
subprocess.check_output(f"tja2fumen {path_tja_tmp}", text=True,
|
||||
shell=True, stderr=subprocess.STDOUT)
|
||||
tb = e.value.output
|
||||
except CalledProcessError as e:
|
||||
tb = str(e)
|
||||
|
||||
elif entry_point == "exe":
|
||||
exe_glob = os.path.join(os.path.split(path_test)[0], "dist", "*.exe")
|
||||
@ -46,9 +48,10 @@ def convert(path_test, path_tja_tmp, entry_point, err_msg=None):
|
||||
subprocess.check_output(f"{exe} {path_tja_tmp}", text=True,
|
||||
shell=True, stderr=subprocess.STDOUT)
|
||||
else:
|
||||
with pytest.raises(CalledProcessError) as e:
|
||||
try:
|
||||
subprocess.check_output(f"{exe} {path_tja_tmp}", text=True,
|
||||
shell=True, stderr=subprocess.STDOUT)
|
||||
tb = e.value.output
|
||||
except CalledProcessError as e:
|
||||
tb = str(e)
|
||||
|
||||
return tb
|
||||
|
@ -9,12 +9,12 @@ from conftest import convert
|
||||
@pytest.mark.parametrize('id_song,err_msg', [
|
||||
['basic_song', None],
|
||||
['basic_song_2P', None],
|
||||
['unsupported', None],
|
||||
['unsupported', 'UserWarning'],
|
||||
['notes_double_kusudama', None],
|
||||
['notes_hands', None],
|
||||
['notes_sim_only', None],
|
||||
['missing_score', None],
|
||||
['missing_balloon', "Not enough values for 'BALLOON:"],
|
||||
['missing_balloon', "UserWarning"],
|
||||
['missing_course', "Invalid COURSE value:"],
|
||||
['missing_level', "Invalid LEVEL value:"]
|
||||
])
|
||||
@ -32,6 +32,10 @@ def test_expected_errors(id_song, err_msg, tmp_path, entry_point):
|
||||
shutil.copy(path_tja, path_tja_tmp)
|
||||
|
||||
# Try to convert TJA file to fumen files, then check the error traceback
|
||||
if err_msg and 'Warning' in err_msg:
|
||||
with pytest.warns():
|
||||
convert(path_test, path_tja_tmp, entry_point)
|
||||
else:
|
||||
tb = convert(path_test, path_tja_tmp, entry_point, err_msg)
|
||||
if err_msg:
|
||||
assert err_msg in tb
|
||||
|
Loading…
Reference in New Issue
Block a user