Exemplo n.º 1
0
    def test_list_option(self):
        # normal behavior
        option = ListOption("test-name", "a,b,c,d", "Test Description")
        self.assertListEqual(option.value, ["a", "b", "c", "d"])

        # re-set value
        option.set("1,2,3,4")
        self.assertListEqual(option.value, ["1", "2", "3", "4"])

        # set list
        option.set(["foo", "bar", "test"])
        self.assertListEqual(option.value, ["foo", "bar", "test"])

        # trailing comma
        option.set("e,f,g,")
        self.assertListEqual(option.value, ["e", "f", "g"])

        # spaces should be trimmed
        option.set(" abc , def   , ghi \t ")
        self.assertListEqual(option.value, ["abc", "def", "ghi"])

        # conversion to string before split
        option.set(123)
        self.assertListEqual(option.value, ["123"])
Exemplo n.º 2
0
    def test_list_option(self):
        # normal behavior
        option = ListOption("test-name", "bar", "Test Description")
        option.set("a,b,c,d")
        self.assertListEqual(option.value, ["a", "b", "c", "d"])

        # trailing comma
        option.set("e,f,g,")
        self.assertListEqual(option.value, ["e", "f", "g"])

        # spaces should be trimmed
        option.set(" abc , def   , ghi \t ")
        self.assertListEqual(option.value, ["abc", "def", "ghi"])

        # conversion to string before split
        option.set(123)
        self.assertListEqual(option.value, ["123"])
Exemplo n.º 3
0
    def test_list_option(self):
        # normal behavior
        option = ListOption("test-name", u"å,b,c,d", "Test Description")
        self.assertListEqual(option.value, [u"å", u"b", u"c", u"d"])

        # re-set value
        option.set(u"1,2,3,4")
        self.assertListEqual(option.value, [u"1", u"2", u"3", u"4"])

        # set list
        option.set([u"foo", u"bår", u"test"])
        self.assertListEqual(option.value, [u"foo", u"bår", u"test"])

        # empty string
        option.set("")
        self.assertListEqual(option.value, [])

        # whitespace string
        option.set("  \t  ")
        self.assertListEqual(option.value, [])

        # empty list
        option.set([])
        self.assertListEqual(option.value, [])

        # trailing comma
        option.set(u"ë,f,g,")
        self.assertListEqual(option.value, [u"ë", u"f", u"g"])

        # leading and trailing whitespace should be trimmed, but only deduped within text
        option.set(" abc , def   , ghi \t  , jkl  mno  ")
        self.assertListEqual(option.value, ["abc", "def", "ghi", "jkl  mno"])

        # Also strip whitespace within a list
        option.set(["\t foo", "bar \t ", " test  123 "])
        self.assertListEqual(option.value, ["foo", "bar", "test  123"])

        # conversion to string before split
        option.set(123)
        self.assertListEqual(option.value, ["123"])
Exemplo n.º 4
0
    def test_list_option(self):
        # normal behavior
        option = ListOption("test-name", "a,b,c,d", "Test Description")
        self.assertListEqual(option.value, ["a", "b", "c", "d"])

        # re-set value
        option.set("1,2,3,4")
        self.assertListEqual(option.value, ["1", "2", "3", "4"])

        # set list
        option.set(["foo", "bar", "test"])
        self.assertListEqual(option.value, ["foo", "bar", "test"])

        # trailing comma
        option.set("e,f,g,")
        self.assertListEqual(option.value, ["e", "f", "g"])

        # leading and trailing whitespace should be trimmed, but only deduped within text
        option.set(" abc , def   , ghi \t  , jkl  mno  ")
        self.assertListEqual(option.value, ["abc", "def", "ghi", "jkl  mno"])

        # Also strip whitespace within a list
        option.set(["\t foo", "bar \t ", " test  123 "])
        self.assertListEqual(option.value, ["foo", "bar", "test  123"])

        # conversion to string before split
        option.set(123)
        self.assertListEqual(option.value, ["123"])