aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py')
-rw-r--r--contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py236
1 files changed, 118 insertions, 118 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py b/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py
index abc7c0a892..f8862d064a 100644
--- a/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py
+++ b/contrib/tools/cython/Cython/Compiler/Tests/TestCmdLine.py
@@ -1,118 +1,118 @@
-
-import sys
-from unittest import TestCase
-try:
- from StringIO import StringIO
-except ImportError:
- from io import StringIO # doesn't accept 'str' in Py2
-
-from .. import Options
-from ..CmdLine import parse_command_line
-
-
-class CmdLineParserTest(TestCase):
- def setUp(self):
- backup = {}
- for name, value in vars(Options).items():
- backup[name] = value
- self._options_backup = backup
-
- def tearDown(self):
- no_value = object()
- for name, orig_value in self._options_backup.items():
- if getattr(Options, name, no_value) != orig_value:
- setattr(Options, name, orig_value)
-
- def test_short_options(self):
- options, sources = parse_command_line([
- '-V', '-l', '-+', '-t', '-v', '-v', '-v', '-p', '-D', '-a', '-3',
- ])
- self.assertFalse(sources)
- self.assertTrue(options.show_version)
- self.assertTrue(options.use_listing_file)
- self.assertTrue(options.cplus)
- self.assertTrue(options.timestamps)
- self.assertTrue(options.verbose >= 3)
- self.assertTrue(Options.embed_pos_in_docstring)
- self.assertFalse(Options.docstrings)
- self.assertTrue(Options.annotate)
- self.assertEqual(options.language_level, 3)
-
- options, sources = parse_command_line([
- '-f', '-2', 'source.pyx',
- ])
- self.assertTrue(sources)
- self.assertTrue(len(sources) == 1)
- self.assertFalse(options.timestamps)
- self.assertEqual(options.language_level, 2)
-
- def test_long_options(self):
- options, sources = parse_command_line([
- '--version', '--create-listing', '--cplus', '--embed', '--timestamps',
- '--verbose', '--verbose', '--verbose',
- '--embed-positions', '--no-docstrings', '--annotate', '--lenient',
- ])
- self.assertFalse(sources)
- self.assertTrue(options.show_version)
- self.assertTrue(options.use_listing_file)
- self.assertTrue(options.cplus)
- self.assertEqual(Options.embed, 'main')
- self.assertTrue(options.timestamps)
- self.assertTrue(options.verbose >= 3)
- self.assertTrue(Options.embed_pos_in_docstring)
- self.assertFalse(Options.docstrings)
- self.assertTrue(Options.annotate)
- self.assertFalse(Options.error_on_unknown_names)
- self.assertFalse(Options.error_on_uninitialized)
-
- options, sources = parse_command_line([
- '--force', 'source.pyx',
- ])
- self.assertTrue(sources)
- self.assertTrue(len(sources) == 1)
- self.assertFalse(options.timestamps)
-
- def test_options_with_values(self):
- options, sources = parse_command_line([
- '--embed=huhu',
- '-I/test/include/dir1', '--include-dir=/test/include/dir2',
- '--include-dir', '/test/include/dir3',
- '--working=/work/dir',
- 'source.pyx',
- '--output-file=/output/dir',
- '--pre-import=/pre/import',
- '--cleanup=3',
- '--annotate-coverage=cov.xml',
- '--gdb-outdir=/gdb/outdir',
- '--directive=wraparound=false',
- ])
- self.assertEqual(sources, ['source.pyx'])
- self.assertEqual(Options.embed, 'huhu')
- self.assertEqual(options.include_path, ['/test/include/dir1', '/test/include/dir2', '/test/include/dir3'])
- self.assertEqual(options.working_path, '/work/dir')
- self.assertEqual(options.output_file, '/output/dir')
- self.assertEqual(Options.pre_import, '/pre/import')
- self.assertEqual(Options.generate_cleanup_code, 3)
- self.assertTrue(Options.annotate)
- self.assertEqual(Options.annotate_coverage_xml, 'cov.xml')
- self.assertTrue(options.gdb_debug)
- self.assertEqual(options.output_dir, '/gdb/outdir')
-
- def test_errors(self):
- def error(*args):
- old_stderr = sys.stderr
- stderr = sys.stderr = StringIO()
- try:
- self.assertRaises(SystemExit, parse_command_line, list(args))
- finally:
- sys.stderr = old_stderr
- self.assertTrue(stderr.getvalue())
-
- error('-1')
- error('-I')
- error('--version=-a')
- error('--version=--annotate=true')
- error('--working')
- error('--verbose=1')
- error('--verbose=1')
- error('--cleanup')
+
+import sys
+from unittest import TestCase
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO # doesn't accept 'str' in Py2
+
+from .. import Options
+from ..CmdLine import parse_command_line
+
+
+class CmdLineParserTest(TestCase):
+ def setUp(self):
+ backup = {}
+ for name, value in vars(Options).items():
+ backup[name] = value
+ self._options_backup = backup
+
+ def tearDown(self):
+ no_value = object()
+ for name, orig_value in self._options_backup.items():
+ if getattr(Options, name, no_value) != orig_value:
+ setattr(Options, name, orig_value)
+
+ def test_short_options(self):
+ options, sources = parse_command_line([
+ '-V', '-l', '-+', '-t', '-v', '-v', '-v', '-p', '-D', '-a', '-3',
+ ])
+ self.assertFalse(sources)
+ self.assertTrue(options.show_version)
+ self.assertTrue(options.use_listing_file)
+ self.assertTrue(options.cplus)
+ self.assertTrue(options.timestamps)
+ self.assertTrue(options.verbose >= 3)
+ self.assertTrue(Options.embed_pos_in_docstring)
+ self.assertFalse(Options.docstrings)
+ self.assertTrue(Options.annotate)
+ self.assertEqual(options.language_level, 3)
+
+ options, sources = parse_command_line([
+ '-f', '-2', 'source.pyx',
+ ])
+ self.assertTrue(sources)
+ self.assertTrue(len(sources) == 1)
+ self.assertFalse(options.timestamps)
+ self.assertEqual(options.language_level, 2)
+
+ def test_long_options(self):
+ options, sources = parse_command_line([
+ '--version', '--create-listing', '--cplus', '--embed', '--timestamps',
+ '--verbose', '--verbose', '--verbose',
+ '--embed-positions', '--no-docstrings', '--annotate', '--lenient',
+ ])
+ self.assertFalse(sources)
+ self.assertTrue(options.show_version)
+ self.assertTrue(options.use_listing_file)
+ self.assertTrue(options.cplus)
+ self.assertEqual(Options.embed, 'main')
+ self.assertTrue(options.timestamps)
+ self.assertTrue(options.verbose >= 3)
+ self.assertTrue(Options.embed_pos_in_docstring)
+ self.assertFalse(Options.docstrings)
+ self.assertTrue(Options.annotate)
+ self.assertFalse(Options.error_on_unknown_names)
+ self.assertFalse(Options.error_on_uninitialized)
+
+ options, sources = parse_command_line([
+ '--force', 'source.pyx',
+ ])
+ self.assertTrue(sources)
+ self.assertTrue(len(sources) == 1)
+ self.assertFalse(options.timestamps)
+
+ def test_options_with_values(self):
+ options, sources = parse_command_line([
+ '--embed=huhu',
+ '-I/test/include/dir1', '--include-dir=/test/include/dir2',
+ '--include-dir', '/test/include/dir3',
+ '--working=/work/dir',
+ 'source.pyx',
+ '--output-file=/output/dir',
+ '--pre-import=/pre/import',
+ '--cleanup=3',
+ '--annotate-coverage=cov.xml',
+ '--gdb-outdir=/gdb/outdir',
+ '--directive=wraparound=false',
+ ])
+ self.assertEqual(sources, ['source.pyx'])
+ self.assertEqual(Options.embed, 'huhu')
+ self.assertEqual(options.include_path, ['/test/include/dir1', '/test/include/dir2', '/test/include/dir3'])
+ self.assertEqual(options.working_path, '/work/dir')
+ self.assertEqual(options.output_file, '/output/dir')
+ self.assertEqual(Options.pre_import, '/pre/import')
+ self.assertEqual(Options.generate_cleanup_code, 3)
+ self.assertTrue(Options.annotate)
+ self.assertEqual(Options.annotate_coverage_xml, 'cov.xml')
+ self.assertTrue(options.gdb_debug)
+ self.assertEqual(options.output_dir, '/gdb/outdir')
+
+ def test_errors(self):
+ def error(*args):
+ old_stderr = sys.stderr
+ stderr = sys.stderr = StringIO()
+ try:
+ self.assertRaises(SystemExit, parse_command_line, list(args))
+ finally:
+ sys.stderr = old_stderr
+ self.assertTrue(stderr.getvalue())
+
+ error('-1')
+ error('-I')
+ error('--version=-a')
+ error('--version=--annotate=true')
+ error('--working')
+ error('--verbose=1')
+ error('--verbose=1')
+ error('--cleanup')