http://bugs.python.org/review/13592/diff/5455/Lib/test/test_re.py
File Lib/test/test_re.py (right):
http://bugs.python.org/review/13592/diff/5455/Lib/test/test_re.py#newcode928
Lib/test/test_re.py:928: self.assertEquals('re.compile("random pattern",
re.UNICODE)', repr(pattern))
3 comments:
1) assertEquals is deprecated, you should use assertEqual instead (without the
final 's'). If you run the tests with -Wd you should get a warning for this;
2) it should be assertEqual(actual, expected), not assertEqual(expected,
actual);
3) to improve readability and to avoid having more than 80 chars per line (see
PEP8), I'd suggest to go on a new line after the first argument of assertEqual,
e.g.:
self.assertEqual(re.compile('random pattern'),
"re.compile('random pattern', re.UNICODE)")
http://bugs.python.org/review/13592/diff/5455/Lib/test/test_re.py#newcode940
Lib/test/test_re.py:940: self.assertEquals('re.compile("random pattern",
re.IGNORECASE|re.DOTALL|re.UNICODE|re.VERBOSE)', repr(pattern))
I'd also add some tests that use the short constants names, e.g. re.I, re.S,
etc.
A test that uses inline flags would be good too (e.g. re.compile('(?i)foo').
http://bugs.python.org/review/13592/diff/5455/Modules/_sre.c
File Modules/_sre.c (right):
http://bugs.python.org/review/13592/diff/5455/Modules/_sre.c#newcode2693
Modules/_sre.c:2693: if (!append_string(list, "re.compile(\""))
Wouldn't this break if the pattern contains a " ?
Maybe using just "re.compile(" and appending the repr of obj->pattern is better.
http://bugs.python.org/review/13592/diff/5467/Lib/test/test_re.py File Lib/test/test_re.py (right): http://bugs.python.org/review/13592/diff/5467/Lib/test/test_re.py#newcode958 Lib/test/test_re.py:958: def test_repr_with_single_quotes_inside(self): For good measure, add a test with ...
Issue 13592: repr(regex) doesn't include actual regex
Created 10 months, 1 week ago by spamfaenger_gmx.de
Modified 2 months, 1 week ago
Reviewers: ezio.melotti, twouters
Base URL: None
Comments: 12