mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Switch tests to pytest and ansible-test.
- Replace nose usage with pytest. - Remove legacy Shippable integration.sh. - Update Makefile to use pytest and ansible-test. - Convert most yield unit tests to pytest parametrize.
This commit is contained in:
@@ -1,121 +1,100 @@
|
||||
import collections
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
from nose.tools import eq_
|
||||
try:
|
||||
from nose.tools import assert_raises_regexp
|
||||
except ImportError:
|
||||
from ansible.compat.six import string_types
|
||||
# Python < 2.7
|
||||
def assert_raises_regexp(expected, regexp, callable, *a, **kw):
|
||||
try:
|
||||
callable(*a, **kw)
|
||||
except expected as e:
|
||||
if isinstance(regexp, string_types):
|
||||
regexp = re.compile(regexp)
|
||||
if not regexp.search(str(e)):
|
||||
raise Exception('"%s" does not match "%s"' %
|
||||
(regexp.pattern, str(e)))
|
||||
else:
|
||||
if hasattr(expected,'__name__'): excName = expected.__name__
|
||||
else: excName = str(expected)
|
||||
raise AssertionError("%s not raised" % excName)
|
||||
|
||||
from ansible.compat.tests import mock
|
||||
import pytest
|
||||
|
||||
from ansible.module_utils.database import (
|
||||
pg_quote_identifier,
|
||||
SQLParseError,
|
||||
)
|
||||
|
||||
# These are all valid strings
|
||||
# The results are based on interpreting the identifier as a table name
|
||||
VALID = {
|
||||
# User quoted
|
||||
'"public.table"': '"public.table"',
|
||||
'"public"."table"': '"public"."table"',
|
||||
'"schema test"."table test"': '"schema test"."table test"',
|
||||
|
||||
# Note: Using nose's generator test cases here so we can't inherit from
|
||||
# unittest.TestCase
|
||||
class TestQuotePgIdentifier(object):
|
||||
# We quote part
|
||||
'public.table': '"public"."table"',
|
||||
'"public".table': '"public"."table"',
|
||||
'public."table"': '"public"."table"',
|
||||
'schema test.table test': '"schema test"."table test"',
|
||||
'"schema test".table test': '"schema test"."table test"',
|
||||
'schema test."table test"': '"schema test"."table test"',
|
||||
|
||||
# These are all valid strings
|
||||
# The results are based on interpreting the identifier as a table name
|
||||
valid = {
|
||||
# User quoted
|
||||
'"public.table"': '"public.table"',
|
||||
'"public"."table"': '"public"."table"',
|
||||
'"schema test"."table test"': '"schema test"."table test"',
|
||||
# Embedded double quotes
|
||||
'table "test"': '"table ""test"""',
|
||||
'public."table ""test"""': '"public"."table ""test"""',
|
||||
'public.table "test"': '"public"."table ""test"""',
|
||||
'schema "test".table': '"schema ""test"""."table"',
|
||||
'"schema ""test""".table': '"schema ""test"""."table"',
|
||||
'"""wat"""."""test"""': '"""wat"""."""test"""',
|
||||
# Sigh, handle these as well:
|
||||
'"no end quote': '"""no end quote"',
|
||||
'schema."table': '"schema"."""table"',
|
||||
'"schema.table': '"""schema"."table"',
|
||||
'schema."table.something': '"schema"."""table"."something"',
|
||||
|
||||
# We quote part
|
||||
'public.table': '"public"."table"',
|
||||
'"public".table': '"public"."table"',
|
||||
'public."table"': '"public"."table"',
|
||||
'schema test.table test': '"schema test"."table test"',
|
||||
'"schema test".table test': '"schema test"."table test"',
|
||||
'schema test."table test"': '"schema test"."table test"',
|
||||
# Embedded dots
|
||||
'"schema.test"."table.test"': '"schema.test"."table.test"',
|
||||
'"schema.".table': '"schema."."table"',
|
||||
'"schema."."table"': '"schema."."table"',
|
||||
'schema.".table"': '"schema".".table"',
|
||||
'"schema".".table"': '"schema".".table"',
|
||||
'"schema.".".table"': '"schema.".".table"',
|
||||
# These are valid but maybe not what the user intended
|
||||
'."table"': '".""table"""',
|
||||
'table.': '"table."',
|
||||
}
|
||||
|
||||
# Embedded double quotes
|
||||
'table "test"': '"table ""test"""',
|
||||
'public."table ""test"""': '"public"."table ""test"""',
|
||||
'public.table "test"': '"public"."table ""test"""',
|
||||
'schema "test".table': '"schema ""test"""."table"',
|
||||
'"schema ""test""".table': '"schema ""test"""."table"',
|
||||
'"""wat"""."""test"""': '"""wat"""."""test"""',
|
||||
# Sigh, handle these as well:
|
||||
'"no end quote': '"""no end quote"',
|
||||
'schema."table': '"schema"."""table"',
|
||||
'"schema.table': '"""schema"."table"',
|
||||
'schema."table.something': '"schema"."""table"."something"',
|
||||
INVALID = {
|
||||
('test.too.many.dots', 'table'): 'PostgreSQL does not support table with more than 3 dots',
|
||||
('"test.too".many.dots', 'database'): 'PostgreSQL does not support database with more than 1 dots',
|
||||
('test.too."many.dots"', 'database'): 'PostgreSQL does not support database with more than 1 dots',
|
||||
('"test"."too"."many"."dots"', 'database'): "PostgreSQL does not support database with more than 1 dots",
|
||||
('"test"."too"."many"."dots"', 'schema'): "PostgreSQL does not support schema with more than 2 dots",
|
||||
('"test"."too"."many"."dots"', 'table'): "PostgreSQL does not support table with more than 3 dots",
|
||||
('"test"."too"."many"."dots"."for"."column"', 'column'): "PostgreSQL does not support column with more than 4 dots",
|
||||
('"table "invalid" double quote"', 'table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema "invalid"""."table "invalid"', 'table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema."table"', 'table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema".', 'table'): 'Identifier name unspecified or unquoted trailing dot',
|
||||
}
|
||||
|
||||
# Embedded dots
|
||||
'"schema.test"."table.test"': '"schema.test"."table.test"',
|
||||
'"schema.".table': '"schema."."table"',
|
||||
'"schema."."table"': '"schema."."table"',
|
||||
'schema.".table"': '"schema".".table"',
|
||||
'"schema".".table"': '"schema".".table"',
|
||||
'"schema.".".table"': '"schema.".".table"',
|
||||
# These are valid but maybe not what the user intended
|
||||
'."table"': '".""table"""',
|
||||
'table.': '"table."',
|
||||
}
|
||||
HOW_MANY_DOTS = (
|
||||
('role', 'role', '"role"',
|
||||
'PostgreSQL does not support role with more than 1 dots'),
|
||||
('db', 'database', '"db"',
|
||||
'PostgreSQL does not support database with more than 1 dots'),
|
||||
('db.schema', 'schema', '"db"."schema"',
|
||||
'PostgreSQL does not support schema with more than 2 dots'),
|
||||
('db.schema.table', 'table', '"db"."schema"."table"',
|
||||
'PostgreSQL does not support table with more than 3 dots'),
|
||||
('db.schema.table.column', 'column', '"db"."schema"."table"."column"',
|
||||
'PostgreSQL does not support column with more than 4 dots'),
|
||||
)
|
||||
|
||||
invalid = {
|
||||
('test.too.many.dots', 'table'): 'PostgreSQL does not support table with more than 3 dots',
|
||||
('"test.too".many.dots', 'database'): 'PostgreSQL does not support database with more than 1 dots',
|
||||
('test.too."many.dots"', 'database'): 'PostgreSQL does not support database with more than 1 dots',
|
||||
('"test"."too"."many"."dots"', 'database'): "PostgreSQL does not support database with more than 1 dots",
|
||||
('"test"."too"."many"."dots"', 'schema'): "PostgreSQL does not support schema with more than 2 dots",
|
||||
('"test"."too"."many"."dots"', 'table'): "PostgreSQL does not support table with more than 3 dots",
|
||||
('"test"."too"."many"."dots"."for"."column"', 'column'): "PostgreSQL does not support column with more than 4 dots",
|
||||
('"table "invalid" double quote"', 'table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema "invalid"""."table "invalid"', 'table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema."table"','table'): 'User escaped identifiers must escape extra quotes',
|
||||
('"schema".', 'table'): 'Identifier name unspecified or unquoted trailing dot',
|
||||
}
|
||||
VALID_QUOTES = ((test, VALID[test]) for test in VALID)
|
||||
INVALID_QUOTES = ((test[0], test[1], INVALID[test]) for test in INVALID)
|
||||
|
||||
def check_valid_quotes(self, identifier, quoted_identifier):
|
||||
eq_(pg_quote_identifier(identifier, 'table'), quoted_identifier)
|
||||
|
||||
def test_valid_quotes(self):
|
||||
for identifier in self.valid:
|
||||
yield self.check_valid_quotes, identifier, self.valid[identifier]
|
||||
@pytest.mark.parametrize("identifier, quoted_identifier", VALID_QUOTES)
|
||||
def test_valid_quotes(identifier, quoted_identifier):
|
||||
assert pg_quote_identifier(identifier, 'table') == quoted_identifier
|
||||
|
||||
def check_invalid_quotes(self, identifier, id_type, msg):
|
||||
assert_raises_regexp(SQLParseError, msg, pg_quote_identifier, *(identifier, id_type))
|
||||
|
||||
def test_invalid_quotes(self):
|
||||
for test in self.invalid:
|
||||
yield self.check_invalid_quotes, test[0], test[1], self.invalid[test]
|
||||
@pytest.mark.parametrize("identifier, id_type, msg", INVALID_QUOTES)
|
||||
def test_invalid_quotes(identifier, id_type, msg):
|
||||
with pytest.raises(SQLParseError) as ex:
|
||||
pg_quote_identifier(identifier, id_type)
|
||||
|
||||
def test_how_many_dots(self):
|
||||
eq_(pg_quote_identifier('role', 'role'), '"role"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support role with more than 1 dots", pg_quote_identifier, *('role.more', 'role'))
|
||||
ex.match(msg)
|
||||
|
||||
eq_(pg_quote_identifier('db', 'database'), '"db"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support database with more than 1 dots", pg_quote_identifier, *('db.more', 'database'))
|
||||
|
||||
eq_(pg_quote_identifier('db.schema', 'schema'), '"db"."schema"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support schema with more than 2 dots", pg_quote_identifier, *('db.schema.more', 'schema'))
|
||||
@pytest.mark.parametrize("identifier, id_type, quoted_identifier, msg", HOW_MANY_DOTS)
|
||||
def test_how_many_dots(identifier, id_type, quoted_identifier, msg):
|
||||
assert pg_quote_identifier(identifier, id_type) == quoted_identifier
|
||||
|
||||
eq_(pg_quote_identifier('db.schema.table', 'table'), '"db"."schema"."table"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support table with more than 3 dots", pg_quote_identifier, *('db.schema.table.more', 'table'))
|
||||
with pytest.raises(SQLParseError) as ex:
|
||||
pg_quote_identifier('%s.more' % identifier, id_type)
|
||||
|
||||
eq_(pg_quote_identifier('db.schema.table.column', 'column'), '"db"."schema"."table"."column"')
|
||||
assert_raises_regexp(SQLParseError, "PostgreSQL does not support column with more than 4 dots", pg_quote_identifier, *('db.schema.table.column.more', 'column'))
|
||||
ex.match(msg)
|
||||
|
||||
@@ -20,96 +20,88 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from nose import tools
|
||||
from ansible.compat.tests import unittest
|
||||
|
||||
from ansible.parsing.splitter import split_args, parse_kv
|
||||
|
||||
import pytest
|
||||
|
||||
# Tests using nose's test generators cannot use unittest base class.
|
||||
# http://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
|
||||
class TestSplitter_Gen:
|
||||
SPLIT_DATA = (
|
||||
(u'a',
|
||||
[u'a'],
|
||||
{u'_raw_params': u'a'}),
|
||||
(u'a=b',
|
||||
[u'a=b'],
|
||||
{u'a': u'b'}),
|
||||
(u'a="foo bar"',
|
||||
[u'a="foo bar"'],
|
||||
{u'a': u'foo bar'}),
|
||||
(u'"foo bar baz"',
|
||||
[u'"foo bar baz"'],
|
||||
{u'_raw_params': '"foo bar baz"'}),
|
||||
(u'foo bar baz',
|
||||
[u'foo', u'bar', u'baz'],
|
||||
{u'_raw_params': u'foo bar baz'}),
|
||||
(u'a=b c="foo bar"',
|
||||
[u'a=b', u'c="foo bar"'],
|
||||
{u'a': u'b', u'c': u'foo bar'}),
|
||||
(u'a="echo \\"hello world\\"" b=bar',
|
||||
[u'a="echo \\"hello world\\""', u'b=bar'],
|
||||
{u'a': u'echo "hello world"', u'b': u'bar'}),
|
||||
(u'a="multi\nline"',
|
||||
[u'a="multi\nline"'],
|
||||
{u'a': u'multi\nline'}),
|
||||
(u'a="blank\n\nline"',
|
||||
[u'a="blank\n\nline"'],
|
||||
{u'a': u'blank\n\nline'}),
|
||||
(u'a="blank\n\n\nlines"',
|
||||
[u'a="blank\n\n\nlines"'],
|
||||
{u'a': u'blank\n\n\nlines'}),
|
||||
(u'a="a long\nmessage\\\nabout a thing\n"',
|
||||
[u'a="a long\nmessage\\\nabout a thing\n"'],
|
||||
{u'a': u'a long\nmessage\\\nabout a thing\n'}),
|
||||
(u'a="multiline\nmessage1\\\n" b="multiline\nmessage2\\\n"',
|
||||
[u'a="multiline\nmessage1\\\n"', u'b="multiline\nmessage2\\\n"'],
|
||||
{u'a': 'multiline\nmessage1\\\n', u'b': u'multiline\nmessage2\\\n'}),
|
||||
(u'a={{jinja}}',
|
||||
[u'a={{jinja}}'],
|
||||
{u'a': u'{{jinja}}'}),
|
||||
(u'a={{ jinja }}',
|
||||
[u'a={{ jinja }}'],
|
||||
{u'a': u'{{ jinja }}'}),
|
||||
(u'a="{{jinja}}"',
|
||||
[u'a="{{jinja}}"'],
|
||||
{u'a': u'{{jinja}}'}),
|
||||
(u'a={{ jinja }}{{jinja2}}',
|
||||
[u'a={{ jinja }}{{jinja2}}'],
|
||||
{u'a': u'{{ jinja }}{{jinja2}}'}),
|
||||
(u'a="{{ jinja }}{{jinja2}}"',
|
||||
[u'a="{{ jinja }}{{jinja2}}"'],
|
||||
{u'a': u'{{ jinja }}{{jinja2}}'}),
|
||||
(u'a={{jinja}} b={{jinja2}}',
|
||||
[u'a={{jinja}}', u'b={{jinja2}}'],
|
||||
{u'a': u'{{jinja}}', u'b': u'{{jinja2}}'}),
|
||||
(u'a="{{jinja}}\n" b="{{jinja2}}\n"',
|
||||
[u'a="{{jinja}}\n"', u'b="{{jinja2}}\n"'],
|
||||
{u'a': u'{{jinja}}\n', u'b': u'{{jinja2}}\n'}),
|
||||
(u'a="café eñyei"',
|
||||
[u'a="café eñyei"'],
|
||||
{u'a': u'café eñyei'}),
|
||||
(u'a=café b=eñyei',
|
||||
[u'a=café', u'b=eñyei'],
|
||||
{u'a': u'café', u'b': u'eñyei'}),
|
||||
(u'a={{ foo | some_filter(\' \', " ") }} b=bar',
|
||||
[u'a={{ foo | some_filter(\' \', " ") }}', u'b=bar'],
|
||||
{u'a': u'{{ foo | some_filter(\' \', " ") }}', u'b': u'bar'}),
|
||||
)
|
||||
SPLIT_DATA = (
|
||||
(u'a',
|
||||
[u'a'],
|
||||
{u'_raw_params': u'a'}),
|
||||
(u'a=b',
|
||||
[u'a=b'],
|
||||
{u'a': u'b'}),
|
||||
(u'a="foo bar"',
|
||||
[u'a="foo bar"'],
|
||||
{u'a': u'foo bar'}),
|
||||
(u'"foo bar baz"',
|
||||
[u'"foo bar baz"'],
|
||||
{u'_raw_params': '"foo bar baz"'}),
|
||||
(u'foo bar baz',
|
||||
[u'foo', u'bar', u'baz'],
|
||||
{u'_raw_params': u'foo bar baz'}),
|
||||
(u'a=b c="foo bar"',
|
||||
[u'a=b', u'c="foo bar"'],
|
||||
{u'a': u'b', u'c': u'foo bar'}),
|
||||
(u'a="echo \\"hello world\\"" b=bar',
|
||||
[u'a="echo \\"hello world\\""', u'b=bar'],
|
||||
{u'a': u'echo "hello world"', u'b': u'bar'}),
|
||||
(u'a="multi\nline"',
|
||||
[u'a="multi\nline"'],
|
||||
{u'a': u'multi\nline'}),
|
||||
(u'a="blank\n\nline"',
|
||||
[u'a="blank\n\nline"'],
|
||||
{u'a': u'blank\n\nline'}),
|
||||
(u'a="blank\n\n\nlines"',
|
||||
[u'a="blank\n\n\nlines"'],
|
||||
{u'a': u'blank\n\n\nlines'}),
|
||||
(u'a="a long\nmessage\\\nabout a thing\n"',
|
||||
[u'a="a long\nmessage\\\nabout a thing\n"'],
|
||||
{u'a': u'a long\nmessage\\\nabout a thing\n'}),
|
||||
(u'a="multiline\nmessage1\\\n" b="multiline\nmessage2\\\n"',
|
||||
[u'a="multiline\nmessage1\\\n"', u'b="multiline\nmessage2\\\n"'],
|
||||
{u'a': 'multiline\nmessage1\\\n', u'b': u'multiline\nmessage2\\\n'}),
|
||||
(u'a={{jinja}}',
|
||||
[u'a={{jinja}}'],
|
||||
{u'a': u'{{jinja}}'}),
|
||||
(u'a={{ jinja }}',
|
||||
[u'a={{ jinja }}'],
|
||||
{u'a': u'{{ jinja }}'}),
|
||||
(u'a="{{jinja}}"',
|
||||
[u'a="{{jinja}}"'],
|
||||
{u'a': u'{{jinja}}'}),
|
||||
(u'a={{ jinja }}{{jinja2}}',
|
||||
[u'a={{ jinja }}{{jinja2}}'],
|
||||
{u'a': u'{{ jinja }}{{jinja2}}'}),
|
||||
(u'a="{{ jinja }}{{jinja2}}"',
|
||||
[u'a="{{ jinja }}{{jinja2}}"'],
|
||||
{u'a': u'{{ jinja }}{{jinja2}}'}),
|
||||
(u'a={{jinja}} b={{jinja2}}',
|
||||
[u'a={{jinja}}', u'b={{jinja2}}'],
|
||||
{u'a': u'{{jinja}}', u'b': u'{{jinja2}}'}),
|
||||
(u'a="{{jinja}}\n" b="{{jinja2}}\n"',
|
||||
[u'a="{{jinja}}\n"', u'b="{{jinja2}}\n"'],
|
||||
{u'a': u'{{jinja}}\n', u'b': u'{{jinja2}}\n'}),
|
||||
(u'a="café eñyei"',
|
||||
[u'a="café eñyei"'],
|
||||
{u'a': u'café eñyei'}),
|
||||
(u'a=café b=eñyei',
|
||||
[u'a=café', u'b=eñyei'],
|
||||
{u'a': u'café', u'b': u'eñyei'}),
|
||||
(u'a={{ foo | some_filter(\' \', " ") }} b=bar',
|
||||
[u'a={{ foo | some_filter(\' \', " ") }}', u'b=bar'],
|
||||
{u'a': u'{{ foo | some_filter(\' \', " ") }}', u'b': u'bar'}),
|
||||
)
|
||||
|
||||
def check_split_args(self, args, expected):
|
||||
tools.eq_(split_args(args), expected)
|
||||
SPLIT_ARGS = ((test[0], test[1]) for test in SPLIT_DATA)
|
||||
PARSE_KV = ((test[0], test[2]) for test in SPLIT_DATA)
|
||||
|
||||
def test_split_args(self):
|
||||
for datapoint in self.SPLIT_DATA:
|
||||
yield self.check_split_args, datapoint[0], datapoint[1]
|
||||
|
||||
def check_parse_kv(self, args, expected):
|
||||
tools.eq_(parse_kv(args), expected)
|
||||
@pytest.mark.parametrize("args, expected", SPLIT_ARGS)
|
||||
def test_split_args(args, expected):
|
||||
assert split_args(args) == expected
|
||||
|
||||
def test_parse_kv(self):
|
||||
for datapoint in self.SPLIT_DATA:
|
||||
try:
|
||||
yield self.check_parse_kv, datapoint[0], datapoint[2]
|
||||
except: pass
|
||||
|
||||
@pytest.mark.parametrize("args, expected", PARSE_KV)
|
||||
def test_parse_kv(args, expected):
|
||||
assert parse_kv(args) == expected
|
||||
|
||||
@@ -20,39 +20,32 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from nose import tools
|
||||
from ansible.compat.tests import unittest
|
||||
|
||||
from ansible.parsing.quoting import unquote
|
||||
|
||||
import pytest
|
||||
|
||||
# Tests using nose's test generators cannot use unittest base class.
|
||||
# http://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
|
||||
class TestUnquote:
|
||||
UNQUOTE_DATA = (
|
||||
(u'1', u'1'),
|
||||
(u'\'1\'', u'1'),
|
||||
(u'"1"', u'1'),
|
||||
(u'"1 \'2\'"', u'1 \'2\''),
|
||||
(u'\'1 "2"\'', u'1 "2"'),
|
||||
(u'\'1 \'2\'\'', u'1 \'2\''),
|
||||
(u'"1\\"', u'"1\\"'),
|
||||
(u'\'1\\\'', u'\'1\\\''),
|
||||
(u'"1 \\"2\\" 3"', u'1 \\"2\\" 3'),
|
||||
(u'\'1 \\\'2\\\' 3\'', u'1 \\\'2\\\' 3'),
|
||||
(u'"', u'"'),
|
||||
(u'\'', u'\''),
|
||||
# Not entirely sure these are good but they match the current
|
||||
# behaviour
|
||||
(u'"1""2"', u'1""2'),
|
||||
(u'\'1\'\'2\'', u'1\'\'2'),
|
||||
(u'"1" 2 "3"', u'1" 2 "3'),
|
||||
(u'"1"\'2\'"3"', u'1"\'2\'"3'),
|
||||
)
|
||||
UNQUOTE_DATA = (
|
||||
(u'1', u'1'),
|
||||
(u'\'1\'', u'1'),
|
||||
(u'"1"', u'1'),
|
||||
(u'"1 \'2\'"', u'1 \'2\''),
|
||||
(u'\'1 "2"\'', u'1 "2"'),
|
||||
(u'\'1 \'2\'\'', u'1 \'2\''),
|
||||
(u'"1\\"', u'"1\\"'),
|
||||
(u'\'1\\\'', u'\'1\\\''),
|
||||
(u'"1 \\"2\\" 3"', u'1 \\"2\\" 3'),
|
||||
(u'\'1 \\\'2\\\' 3\'', u'1 \\\'2\\\' 3'),
|
||||
(u'"', u'"'),
|
||||
(u'\'', u'\''),
|
||||
# Not entirely sure these are good but they match the current
|
||||
# behaviour
|
||||
(u'"1""2"', u'1""2'),
|
||||
(u'\'1\'\'2\'', u'1\'\'2'),
|
||||
(u'"1" 2 "3"', u'1" 2 "3'),
|
||||
(u'"1"\'2\'"3"', u'1"\'2\'"3'),
|
||||
)
|
||||
|
||||
def check_unquote(self, quoted, expected):
|
||||
tools.eq_(unquote(quoted), expected)
|
||||
|
||||
def test_unquote(self):
|
||||
for datapoint in self.UNQUOTE_DATA:
|
||||
yield self.check_unquote, datapoint[0], datapoint[1]
|
||||
@pytest.mark.parametrize("quoted, expected", UNQUOTE_DATA)
|
||||
def test_unquote(quoted, expected):
|
||||
assert unquote(quoted) == expected
|
||||
|
||||
Reference in New Issue
Block a user