added invalid tests
parent
3d528f85cb
commit
d019601298
|
@ -0,0 +1,6 @@
|
||||||
|
# comment
|
||||||
|
heavy:
|
||||||
|
mouse2:
|
||||||
|
snort: attack
|
||||||
|
'e':
|
||||||
|
giggle: attack
|
|
@ -0,0 +1,6 @@
|
||||||
|
# comment
|
||||||
|
heavy:
|
||||||
|
mouse8:
|
||||||
|
hold: attack
|
||||||
|
blarg:
|
||||||
|
toggle: attack
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
Tests that we can import and execute the most basic valid test file.
|
Tests that we can import and execute the most basic valid test file.
|
||||||
Uses: tests/validYAML.yaml
|
Uses: tests/basic_test.yaml
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
import tfscript.cli
|
import tfscript.cli
|
||||||
|
@ -10,21 +10,21 @@ class TestCLI:
|
||||||
|
|
||||||
def test_debug_opt(self):
|
def test_debug_opt(self):
|
||||||
"""Is debug argument available?"""
|
"""Is debug argument available?"""
|
||||||
with ArgvContext('tfscript', '-d', 'tests/validYAML.yaml'):
|
with ArgvContext('tfscript', '-d', 'tests/basic_test.yaml'):
|
||||||
parser = tfscript.cli.parseCLI()
|
parser = tfscript.cli.parseCLI()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
assert args.debug == True
|
assert args.debug == True
|
||||||
|
|
||||||
def test_dry_run_opt(self):
|
def test_dry_run_opt(self):
|
||||||
"""Is dry-run argument available?"""
|
"""Is dry-run argument available?"""
|
||||||
with ArgvContext('tfscript', '-n', 'tests/validYAML.yaml'):
|
with ArgvContext('tfscript', '-n', 'tests/basic_test.yaml'):
|
||||||
parser = tfscript.cli.parseCLI()
|
parser = tfscript.cli.parseCLI()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
assert args.dry_run == True
|
assert args.dry_run == True
|
||||||
|
|
||||||
def test_directory_opt(self):
|
def test_directory_opt(self):
|
||||||
"""Use . because it's sure to exist on all platforms."""
|
"""Use . because it's sure to exist on all platforms."""
|
||||||
with ArgvContext('tfscript', '--directory', '.', 'tests/validYAML.yaml'):
|
with ArgvContext('tfscript', '--directory', '.', 'tests/basic_test.yaml'):
|
||||||
parser = tfscript.cli.parseCLI()
|
parser = tfscript.cli.parseCLI()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
assert args.directory == '.'
|
assert args.directory == '.'
|
||||||
|
|
|
@ -1,15 +1,36 @@
|
||||||
"""
|
"""
|
||||||
Tests that we can import and execute the most basic valid test file.
|
Tests that we can import and execute the most basic valid test file.
|
||||||
Uses: tests/validYAML.yaml
|
Uses: tests/basic_test.yaml
|
||||||
|
tests/mega.yaml
|
||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
import tfscript.cli
|
import tfscript.cli
|
||||||
|
import os
|
||||||
from cli_test_helpers import ArgvContext, shell
|
from cli_test_helpers import ArgvContext, shell
|
||||||
|
|
||||||
class TestValidYaml:
|
class TestValidYaml:
|
||||||
|
|
||||||
def test_parseValidFile(self, tmp_path):
|
def test_parseValidFile(self, tmp_path, capsys):
|
||||||
"""Parse the basic test file."""
|
"""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),
|
with ArgvContext('tfscript', '--directory', str(tmp_path),
|
||||||
'-d', 'tests/validYAML.yaml'):
|
'-d', 'tests/basic_test.yaml'):
|
||||||
tfscript.cli.main()
|
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")
|
||||||
|
|
Loading…
Reference in New Issue