tfscript/tests/test_valid_yaml.py

37 lines
1.3 KiB
Python
Raw Normal View History

2022-08-13 12:39:33 -04:00
"""
Tests that we can import and execute the most basic valid test file.
2022-08-13 16:03:43 -04:00
Uses: tests/basic_test.yaml
tests/mega.yaml
2022-08-13 12:39:33 -04:00
"""
import pytest
import tfscript.cli
2022-08-13 16:03:43 -04:00
import os
2022-08-13 12:39:33 -04:00
from cli_test_helpers import ArgvContext, shell
class TestValidYaml:
2022-08-13 16:03:43 -04:00
def test_parseValidFile(self, tmp_path, capsys):
2022-08-13 12:39:33 -04:00
"""Parse the basic test file."""
2022-08-13 16:03:43 -04:00
with capsys.disabled():
print(os.linesep + "Basic test output in {}".format(str(tmp_path)))
with ArgvContext('tfscript', '--directory', str(tmp_path),
'-d', 'tests/basic_test.yaml'):
tfscript.cli.main()
def test_megabyteYamlFile(self, tmp_path, capsys):
"""Parse the test file that produces multi-megabyte output."""
with capsys.disabled():
print(os.linesep + "Multi-megabyte test output in {}".format(str(tmp_path)))
2022-08-13 12:39:33 -04:00
with ArgvContext('tfscript', '--directory', str(tmp_path),
2022-08-13 16:03:43 -04:00
'-d', 'tests/basic_test.yaml'):
2022-08-13 12:39:33 -04:00
tfscript.cli.main()
2022-08-13 16:03:43 -04:00
def test_invalidKeyBind(self):
"""Test handling of invalid YAML exception. Doesn't capture output."""
with ArgvContext('tfscript', 'tests/invalid_keybind.yaml'):
with pytest.raises(SystemExit):
tfscript.cli.main()
pytest.fail("Should abort without positional filename argument")