37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""
|
|
Tests that we can import and execute the most basic valid test file.
|
|
Uses: tests/basic_test.yaml
|
|
tests/mega.yaml
|
|
"""
|
|
import pytest
|
|
import tfscript.cli
|
|
import os
|
|
from cli_test_helpers import ArgvContext, shell
|
|
|
|
class TestValidYaml:
|
|
|
|
def test_parseValidFile(self, tmp_path, capsys):
|
|
"""Parse the basic test file."""
|
|
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)))
|
|
|
|
with ArgvContext('tfscript', '--directory', str(tmp_path),
|
|
'-d', 'tests/basic_test.yaml'):
|
|
tfscript.cli.main()
|
|
|
|
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")
|