summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2018-11-28 15:49:16 +0100
committerGeorg Brandl <georg@python.org>2018-11-28 15:49:16 +0100
commitcdb2a89a25131f46a09a5497e56196c2fe69e184 (patch)
treec968abf8f6ab5ad17e6bc96624c12e1600e1ddeb /tests
parentb9ae9547d99e4219df253ddeb61598c26b0f3032 (diff)
downloadpygments-cdb2a89a25131f46a09a5497e56196c2fe69e184.tar.gz
Fix invalid escapes due to missing raw string prefix.
Diffstat (limited to 'tests')
-rw-r--r--tests/run.py6
-rw-r--r--tests/test_html_formatter.py4
-rw-r--r--tests/test_rtf_formatter.py2
3 files changed, 9 insertions, 3 deletions
diff --git a/tests/run.py b/tests/run.py
index 07665b2a..41279bef 100644
--- a/tests/run.py
+++ b/tests/run.py
@@ -16,6 +16,7 @@ from __future__ import print_function
import os
import sys
+import warnings
# only find tests in this directory
if os.path.dirname(__file__):
@@ -31,6 +32,11 @@ except ImportError:
# make sure the current source is first on sys.path
sys.path.insert(0, '..')
+# make FutureWarnings (coming from Regex syntax most likely) and
+# DeprecationWarnings (coming from invalid escapes due to non-raw strings)
+# an error
+warnings.filterwarnings("error", category=DeprecationWarning)
+
if '--with-coverage' not in sys.argv:
# if running with coverage, pygments should not be imported before coverage
# is started, otherwise it will count already executed lines as uncovered
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py
index 79990edd..10450c56 100644
--- a/tests/test_html_formatter.py
+++ b/tests/test_html_formatter.py
@@ -100,7 +100,7 @@ class HtmlFormatterTest(unittest.TestCase):
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
- self.assertTrue(re.search("<pre>\s+1\s+2\s+3", html))
+ self.assertTrue(re.search(r"<pre>\s+1\s+2\s+3", html))
def test_linenos_with_startnum(self):
optdict = dict(linenos=True, linenostart=5)
@@ -108,7 +108,7 @@ class HtmlFormatterTest(unittest.TestCase):
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
html = outfile.getvalue()
- self.assertTrue(re.search("<pre>\s+5\s+6\s+7", html))
+ self.assertTrue(re.search(r"<pre>\s+5\s+6\s+7", html))
def test_lineanchors(self):
optdict = dict(lineanchors="foo")
diff --git a/tests/test_rtf_formatter.py b/tests/test_rtf_formatter.py
index 756c03a9..44da5768 100644
--- a/tests/test_rtf_formatter.py
+++ b/tests/test_rtf_formatter.py
@@ -80,7 +80,7 @@ class RtfFormatterTest(StringTests, unittest.TestCase):
self.assertEndsWith(result, expected+self.foot, msg)
def test_escape_characters(self):
- t = u'\ {{'
+ t = u'\\ {{'
result = self.format_rtf(t)
expected = (r'\\ \{\{')
if not result.endswith(self.foot):