summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-09-06 19:17:14 -0700
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-09-06 19:17:14 -0700
commitf5e94b366fcffd141890a4bd8c9d2259afd1f43c (patch)
treed51cda599f1703f9e69c731049761def9c2ff4c4 /tests
parent7801d80ebaf2851ec0647733e385e88e90b2ae18 (diff)
downloadcmd2-git-f5e94b366fcffd141890a4bd8c9d2259afd1f43c.tar.gz
Use attrs on Statement object to do immutability
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parsing.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index da1fcb4d..b4de88ad 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -5,6 +5,7 @@ Test the parsing logic in parsing.py
Copyright 2017 Todd Leonhardt <todd.leonhardt@gmail.com>
Released under MIT license, see LICENSE file
"""
+import attr
import pytest
import cmd2
@@ -639,7 +640,8 @@ def test_parse_command_only_multiline(parser):
assert statement.command_and_args == line
assert statement.args == statement
-def test_statement_initialization(parser):
+
+def test_statement_initialization():
string = 'alias'
statement = cmd2.Statement(string)
assert string == statement
@@ -657,3 +659,15 @@ def test_statement_initialization(parser):
assert not statement.pipe_to
assert statement.output == ''
assert statement.output_to == ''
+
+
+def test_statement_is_immutable():
+ string = 'foo'
+ statement = cmd2.Statement(string)
+ assert string == statement
+ assert statement.args == statement
+ assert statement.raw == ''
+ with pytest.raises(attr.exceptions.FrozenInstanceError):
+ statement.args = 'bar'
+ with pytest.raises(attr.exceptions.FrozenInstanceError):
+ statement.raw = 'baz'