提交 5c0c0440 编写于 作者: L Lukáš Doktor

docs: Add note regarding public properties

This should help beginners to identify the issue when accidentally
overriding test's public variables. Also add a unittest to support this
note.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 348d9b6d
......@@ -58,6 +58,10 @@ Note that the test class provides you with a number of convenience attributes:
you can find that more information at :doc:`Mux`.
* And many more (see :mod:`avocado.core.test.Test`)
To minimize the accidental clashes we define the public ones as properties
so if you see something like ``AttributeError: can't set attribute`` double
you are not overriding these.
Test statuses
=============
......
......@@ -98,6 +98,11 @@ class TestClassTestUnit(unittest.TestCase):
self.assertRaises(exceptions.TestSetupFail, self.DummyTest, "test",
test.TestName(1, "name"), base_logdir=self.tmpdir)
def testTryOverrideTestVariable(self):
test = self.DummyTest(base_logdir=self.tmpdir)
self.assertRaises(AttributeError, setattr, test, "name", "whatever")
self.assertRaises(AttributeError, setattr, test, "status", "whatever")
class TestClassTest(unittest.TestCase):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册