Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_tools.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 6d0c54b99ca9 |
| children | f783db4a58ba |
| rev | line source |
|---|---|
|
75257
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
1 """Tests for scripts in the Tools directory. |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
2 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
3 This file contains regression tests for some of the scripts found in the |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
4 Tools directory of a Python checkout or tarball, such as reindent.py. |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
5 """ |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
6 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
7 import os |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
8 import unittest |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
9 import sysconfig |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
10 from test import test_support |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
11 from test.script_helper import assert_python_ok |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
12 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
13 if not sysconfig.is_python_build(): |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
14 # XXX some installers do contain the tools, should we detect that |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
15 # and run the tests in that case too? |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
16 raise unittest.SkipTest('test irrelevant for an installed Python') |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
17 |
|
78956
6d0c54b99ca9
backport from the trunk, to fix test_tools with srcdir != builddir
doko@ubuntu.com
parents:
75257
diff
changeset
|
18 basepath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), |
|
6d0c54b99ca9
backport from the trunk, to fix test_tools with srcdir != builddir
doko@ubuntu.com
parents:
75257
diff
changeset
|
19 'Tools') |
|
75257
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
20 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
21 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
22 class ReindentTests(unittest.TestCase): |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
23 script = os.path.join(basepath, 'scripts', 'reindent.py') |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
24 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
25 def test_noargs(self): |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
26 assert_python_ok(self.script) |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
27 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
28 def test_help(self): |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
29 rc, out, err = assert_python_ok(self.script, '-h') |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
30 self.assertEqual(out, b'') |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
31 self.assertGreater(err, b'') |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
32 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
33 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
34 def test_main(): |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
35 test_support.run_unittest(ReindentTests) |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
36 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
37 |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
38 if __name__ == '__main__': |
|
020364d3e359
Add test file for scripts in Tools (#13447).
Éric Araujo <merwok@netwok.org>
parents:
diff
changeset
|
39 unittest.main() |
