#!/www/python/bin/python
"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/test_history.py $
$Id: test_history.py 23314 2004-01-07 18:24:53Z abenard $
"""

from sancho.unittest import TestScenario, parse_args, run_scenarios
from dulcinea.specified_list import StringList

tested_modules = [ "dulcinea.specified_list" ]

class Test (TestScenario):

    def check_stringlist (self):
        self.test_stmt("s=StringList()")
        self.test_exc("s=StringList([1])", TypeError)
        self.test_stmt("s=StringList(['a'])")
        self.test_stmt("s.append('b')")
        self.test_val("list(s)", ['a', 'b'])
        self.test_stmt("s.insert(1, 'c')")
        self.test_val("list(s)", ['a', 'c', 'b'])
        self.test_stmt("s.insert(0, 'd')")
        self.test_val("list(s)", ['d', 'a', 'c', 'b'])
        self.test_exc("s.insert(0, 3)", TypeError)
        self.test_stmt("s.insert(7, 'e')")
        self.test_val("list(s)", ['d', 'a', 'c', 'b', 'e'])
        self.test_exc("s[0] = 7", TypeError)
        self.test_stmt("s[0] = 'f'")
        self.test_val("list(s)", ['f', 'a', 'c', 'b', 'e'])
        self.test_exc("s[3:4] = ['a', 4]", TypeError)
        self.test_stmt("s[3:4] = ['a', 'b']")
        self.test_val("list(s)", ['f', 'a', 'c', 'a', 'b', 'e'])
        self.test_exc("s.extend(['a', 4])", TypeError)
        self.test_stmt("s.extend(['a', 'b'])")
        self.test_val("list(s)", ['f', 'a', 'c', 'a', 'b', 'e', 'a', 'b'])

if __name__ == "__main__":
    (scenarios, options) = parse_args()
    run_scenarios (scenarios, options)
