コード例 #1
0
    def test_join_literals(self):
        s = safe_str.join([literal('foo'), 'bar'], ',')
        self.assertEqual(s.bits, (literal('foo'), ',bar'))

        s = safe_str.join([shell_literal('foo'), 'bar'], ',')
        self.assertEqual(s.bits, (shell_literal('foo'), ',bar'))

        s = safe_str.join([literal('foo'), 'bar'], literal(','))
        self.assertEqual(s.bits, (literal('foo,'), 'bar'))

        s = safe_str.join([shell_literal('foo'), 'bar'], shell_literal(','))
        self.assertEqual(s.bits, (shell_literal('foo,'), 'bar'))
コード例 #2
0
    def test_join_strings(self):
        s = safe_str.join(['foo'], ',')
        self.assertEqual(s, 'foo')

        s = safe_str.join(['foo', 'bar'], ',')
        self.assertEqual(s, 'foo,bar')
コード例 #3
0
    def test_join_empty(self):
        s = safe_str.join([], ',')
        self.assertEqual(s, '')

        s = safe_str.join([], literal(','))
        self.assertEqual(s, '')