quoted-strings: Rename tests names for clarity

And move only-when-needed tests at the end for readability.
pull/253/head
Adrien Vergé 5 years ago
parent 1a13837e84
commit e284d74be1

@ -137,17 +137,17 @@ class QuotedTestCase(RuleTestCase):
' word 2"\n', ' word 2"\n',
conf, problem1=(9, 3)) conf, problem1=(9, 3))
def test_disallow_redundant_quotes(self): def test_single_quotes_required(self):
conf = 'quoted-strings: {required: only-when-needed}\n' conf = 'quoted-strings: {quote-type: single, required: true}\n'
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' 'string1: foo\n' # fails
'string2: "foo"\n' # fails 'string2: "foo"\n' # fails
'string3: "true"\n' 'string3: "true"\n' # fails
'string4: "123"\n' 'string4: "123"\n' # fails
'string5: \'bar\'\n' # fails 'string5: \'bar\'\n'
'string6: !!str genericstring\n' 'string6: !!str genericstring\n'
'string7: !!str 456\n' 'string7: !!str 456\n'
'string8: !!str "quotedgenericstring"\n' 'string8: !!str "quotedgenericstring"\n'
@ -155,7 +155,8 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf, problem1=(5, 10), problem2=(8, 10)) conf, problem1=(4, 10), problem2=(5, 10),
problem3=(6, 10), problem4=(7, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
' line 1\n' ' line 1\n'
@ -164,25 +165,24 @@ class QuotedTestCase(RuleTestCase):
' word 1\n' ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 3:\n' 'multiline string 3:\n'
' word 1\n' ' word 1\n' # fails
' word 2\n' ' word 2\n'
'multiline string 4:\n' 'multiline string 4:\n'
' "word 1\\\n' # fails ' "word 1\\\n' # fails
' word 2"\n', ' word 2"\n',
conf, problem1=(12, 3)) conf, problem1=(9, 3), problem2=(12, 3))
def test_disallow_redundant_single_quotes(self): def test_any_quotes_not_required(self):
conf = 'quoted-strings: {quote-type: single, ' + \ conf = 'quoted-strings: {quote-type: any, required: false}\n'
'required: only-when-needed}\n'
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' 'string1: foo\n'
'string2: "foo"\n' # fails 'string2: "foo"\n'
'string3: "true"\n' # fails 'string3: "true"\n'
'string4: "123"\n' # fails 'string4: "123"\n'
'string5: \'bar\'\n' # fails 'string5: \'bar\'\n'
'string6: !!str genericstring\n' 'string6: !!str genericstring\n'
'string7: !!str 456\n' 'string7: !!str 456\n'
'string8: !!str "quotedgenericstring"\n' 'string8: !!str "quotedgenericstring"\n'
@ -190,8 +190,7 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf, problem1=(5, 10), problem2=(6, 10), conf)
problem3=(7, 10), problem4=(8, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
' line 1\n' ' line 1\n'
@ -203,17 +202,17 @@ class QuotedTestCase(RuleTestCase):
' word 1\n' ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 4:\n' 'multiline string 4:\n'
' "word 1\\\n' # fails ' "word 1\\\n'
' word 2"\n', ' word 2"\n',
conf, problem1=(12, 3)) conf)
def test_single_quotes_required(self): def test_single_quotes_not_required(self):
conf = 'quoted-strings: {quote-type: single, required: true}\n' conf = 'quoted-strings: {quote-type: single, required: false}\n'
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' # fails 'string1: foo\n'
'string2: "foo"\n' # fails 'string2: "foo"\n' # fails
'string3: "true"\n' # fails 'string3: "true"\n' # fails
'string4: "123"\n' # fails 'string4: "123"\n' # fails
@ -225,7 +224,7 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf, problem1=(4, 10), problem2=(5, 10), conf, problem2=(5, 10),
problem3=(6, 10), problem4=(7, 10)) problem3=(6, 10), problem4=(7, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
@ -235,20 +234,20 @@ class QuotedTestCase(RuleTestCase):
' word 1\n' ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 3:\n' 'multiline string 3:\n'
' word 1\n' # fails ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 4:\n' 'multiline string 4:\n'
' "word 1\\\n' # fails ' "word 1\\\n' # fails
' word 2"\n', ' word 2"\n',
conf, problem1=(9, 3), problem2=(12, 3)) conf, problem1=(12, 3))
def test_any_quotes_relaxed(self): def test_quotes_required(self):
conf = 'quoted-strings: {quote-type: any, required: false}\n' conf = 'quoted-strings: {quote-type: any, required: true}\n'
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' 'string1: foo\n' # fails
'string2: "foo"\n' 'string2: "foo"\n'
'string3: "true"\n' 'string3: "true"\n'
'string4: "123"\n' 'string4: "123"\n'
@ -260,7 +259,7 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf) conf, problem2=(4, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
' line 1\n' ' line 1\n'
@ -269,24 +268,24 @@ class QuotedTestCase(RuleTestCase):
' word 1\n' ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 3:\n' 'multiline string 3:\n'
' word 1\n' ' word 1\n' # fails
' word 2\n' ' word 2\n'
'multiline string 4:\n' 'multiline string 4:\n'
' "word 1\\\n' ' "word 1\\\n'
' word 2"\n', ' word 2"\n',
conf) conf, problem1=(9, 3))
def test_single_quotes_relaxed(self): def test_only_when_needed(self):
conf = 'quoted-strings: {quote-type: single, required: false}\n' conf = 'quoted-strings: {required: only-when-needed}\n'
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' 'string1: foo\n'
'string2: "foo"\n' # fails 'string2: "foo"\n' # fails
'string3: "true"\n' # fails 'string3: "true"\n'
'string4: "123"\n' # fails 'string4: "123"\n'
'string5: \'bar\'\n' 'string5: \'bar\'\n' # fails
'string6: !!str genericstring\n' 'string6: !!str genericstring\n'
'string7: !!str 456\n' 'string7: !!str 456\n'
'string8: !!str "quotedgenericstring"\n' 'string8: !!str "quotedgenericstring"\n'
@ -294,8 +293,7 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf, problem2=(5, 10), conf, problem1=(5, 10), problem2=(8, 10))
problem3=(6, 10), problem4=(7, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
' line 1\n' ' line 1\n'
@ -311,17 +309,18 @@ class QuotedTestCase(RuleTestCase):
' word 2"\n', ' word 2"\n',
conf, problem1=(12, 3)) conf, problem1=(12, 3))
def test_quotes_required(self): def test_only_when_needed_single_quotes(self):
conf = 'quoted-strings: {quote-type: any, required: true}\n' conf = ('quoted-strings: {quote-type: single,\n'
' required: only-when-needed}\n')
self.check('---\n' self.check('---\n'
'boolean1: true\n' 'boolean1: true\n'
'number1: 123\n' 'number1: 123\n'
'string1: foo\n' # fails 'string1: foo\n'
'string2: "foo"\n' 'string2: "foo"\n' # fails
'string3: "true"\n' 'string3: "true"\n' # fails
'string4: "123"\n' 'string4: "123"\n' # fails
'string5: \'bar\'\n' 'string5: \'bar\'\n' # fails
'string6: !!str genericstring\n' 'string6: !!str genericstring\n'
'string7: !!str 456\n' 'string7: !!str 456\n'
'string8: !!str "quotedgenericstring"\n' 'string8: !!str "quotedgenericstring"\n'
@ -329,7 +328,8 @@ class QuotedTestCase(RuleTestCase):
'integer: !!int intstring\n' 'integer: !!int intstring\n'
'boolean2: !!bool boolstring\n' 'boolean2: !!bool boolstring\n'
'boolean3: !!bool "quotedboolstring"\n', 'boolean3: !!bool "quotedboolstring"\n',
conf, problem2=(4, 10)) conf, problem1=(5, 10), problem2=(6, 10),
problem3=(7, 10), problem4=(8, 10))
self.check('---\n' self.check('---\n'
'multiline string 1: |\n' 'multiline string 1: |\n'
' line 1\n' ' line 1\n'
@ -338,9 +338,9 @@ class QuotedTestCase(RuleTestCase):
' word 1\n' ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 3:\n' 'multiline string 3:\n'
' word 1\n' # fails ' word 1\n'
' word 2\n' ' word 2\n'
'multiline string 4:\n' 'multiline string 4:\n'
' "word 1\\\n' ' "word 1\\\n' # fails
' word 2"\n', ' word 2"\n',
conf, problem1=(9, 3)) conf, problem1=(12, 3))

Loading…
Cancel
Save