diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 07:35:56 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 07:35:56 -0500 |
commit | 1f5057dc7d6b7d02084ee15e2d93fb43d142c630 (patch) | |
tree | d32b212549dbd14af64d6ec94006cb4ad85bc9bd | |
parent | bc0a40ecb0995d0ac88ea67a76db4fc1d1dd35b3 (diff) | |
download | python-coveragepy-git-1f5057dc7d6b7d02084ee15e2d93fb43d142c630.tar.gz |
Check that our tokenizer works properly for dos-line-ended files.
--HG--
rename : test/stress_phystoken.txt => test/stress_phystoken.tok
-rw-r--r-- | test/stress_phystoken.tok (renamed from test/stress_phystoken.txt) | 4 | ||||
-rw-r--r-- | test/stress_phystoken_dos.tok | 52 | ||||
-rw-r--r-- | test/test_phystokens.py | 4 |
3 files changed, 57 insertions, 3 deletions
diff --git a/test/stress_phystoken.txt b/test/stress_phystoken.tok index a1e41490..8d1b6bec 100644 --- a/test/stress_phystoken.txt +++ b/test/stress_phystoken.tok @@ -1,6 +1,6 @@ # Here's some random Python so that test_tokenize_myself will have some -# stressful stuff to try. This file is .txt instead of .py so pylint won't -# complain about it. +# stressful stuff to try. This file is .tok instead of .py so pylint won't +# complain about it, check_eol won't look at it, etc. first_back = """\ hey there! diff --git a/test/stress_phystoken_dos.tok b/test/stress_phystoken_dos.tok new file mode 100644 index 00000000..b08fd70e --- /dev/null +++ b/test/stress_phystoken_dos.tok @@ -0,0 +1,52 @@ +# Here's some random Python so that test_tokenize_myself will have some
+# stressful stuff to try. This file is .tok instead of .py so pylint won't
+# complain about it, check_eol won't look at it, etc.
+
+first_back = """\
+hey there!
+"""
+
+other_back = """
+hey \
+there
+"""
+
+lots_of_back = """\
+hey \
+there
+"""
+# This next line is supposed to have trailing whitespace:
+fake_back = """\
+ouch
+"""
+
+# Lots of difficulty happens with code like:
+#
+# fake_back = """\
+# ouch
+# """
+#
+# Ugh, the edge cases...
+
+# What about a comment like this\
+"what's this string doing here?"
+
+class C(object):
+ def there():
+ this = 5 + \
+ 7
+ that = \
+ "a continued line"
+
+cont1 = "one line of text" + \
+ "another line of text"
+
+a_long_string = \
+ "part 1" \
+ "2" \
+ "3 is longer"
+
+def hello():
+ print("Hello world!")
+
+hello()
diff --git a/test/test_phystokens.py b/test/test_phystokens.py index 6b16d68e..6b533cf6 100644 --- a/test/test_phystokens.py +++ b/test/test_phystokens.py @@ -75,5 +75,7 @@ class PhysTokensTest(CoverageTest): def test_stress(self): # Check the tokenization of a stress-test file. - stress = os.path.join(HERE, "stress_phystoken.txt") + stress = os.path.join(HERE, "stress_phystoken.tok") + self.check_file_tokenization(stress) + stress = os.path.join(HERE, "stress_phystoken_dos.tok") self.check_file_tokenization(stress) |