Python sys._xoptions() Examples
The following are 7
code examples of sys._xoptions().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sys
, or try the search function
.
Example #1
Source File: test_cmd_line.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_xoptions(self): def get_xoptions(*args): # use subprocess module directly because test.support.script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') out = subprocess.check_output(args) opts = eval(out.splitlines()[0]) return opts opts = get_xoptions() self.assertEqual(opts, {}) opts = get_xoptions('-Xa', '-Xb=c,d=e') self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
Example #2
Source File: test_cmd_line.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_showrefcount(self): def run_python(*args): # this is similar to assert_python_ok but doesn't strip # the refcount from stderr. It can be replaced once # assert_python_ok stops doing that. cmd = [sys.executable] cmd.extend(args) PIPE = subprocess.PIPE p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE) out, err = p.communicate() p.stdout.close() p.stderr.close() rc = p.returncode self.assertEqual(rc, 0) return rc, out, err code = 'import sys; print(sys._xoptions)' # normally the refcount is hidden rc, out, err = run_python('-c', code) self.assertEqual(out.rstrip(), b'{}') self.assertEqual(err, b'') # "-X showrefcount" shows the refcount, but only in debug builds rc, out, err = run_python('-X', 'showrefcount', '-c', code) self.assertEqual(out.rstrip(), b"{'showrefcount': True}") if hasattr(sys, 'gettotalrefcount'): # debug build self.assertRegex(err, br'^\[\d+ refs, \d+ blocks\]') else: self.assertEqual(err, b'')
Example #3
Source File: test_cmd_line.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_xoptions(self): def get_xoptions(*args): # use subprocess module directly because test.script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') out = subprocess.check_output(args) opts = eval(out.splitlines()[0]) return opts opts = get_xoptions() self.assertEqual(opts, {}) opts = get_xoptions('-Xa', '-Xb=c,d=e') self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
Example #4
Source File: test_cmd_line.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_showrefcount(self): def run_python(*args): # this is similar to assert_python_ok but doesn't strip # the refcount from stderr. It can be replaced once # assert_python_ok stops doing that. cmd = [sys.executable] cmd.extend(args) PIPE = subprocess.PIPE p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE) out, err = p.communicate() p.stdout.close() p.stderr.close() rc = p.returncode self.assertEqual(rc, 0) return rc, out, err code = 'import sys; print(sys._xoptions)' # normally the refcount is hidden rc, out, err = run_python('-c', code) self.assertEqual(out.rstrip(), b'{}') self.assertEqual(err, b'') # "-X showrefcount" shows the refcount, but only in debug builds rc, out, err = run_python('-X', 'showrefcount', '-c', code) self.assertEqual(out.rstrip(), b"{'showrefcount': True}") if hasattr(sys, 'gettotalrefcount'): # debug build self.assertRegex(err, br'^\[\d+ refs, \d+ blocks\]') else: self.assertEqual(err, b'')
Example #5
Source File: test_cmd_line.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_xoptions(self): def get_xoptions(*args): # use subprocess module directly because test.support.script_helper adds # "-X faulthandler" to the command line args = (sys.executable, '-E') + args args += ('-c', 'import sys; print(sys._xoptions)') out = subprocess.check_output(args) opts = eval(out.splitlines()[0]) return opts opts = get_xoptions() self.assertEqual(opts, {}) opts = get_xoptions('-Xa', '-Xb=c,d=e') self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
Example #6
Source File: test_cmd_line.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_showrefcount(self): def run_python(*args): # this is similar to assert_python_ok but doesn't strip # the refcount from stderr. It can be replaced once # assert_python_ok stops doing that. cmd = [sys.executable] cmd.extend(args) PIPE = subprocess.PIPE p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE) out, err = p.communicate() p.stdout.close() p.stderr.close() rc = p.returncode self.assertEqual(rc, 0) return rc, out, err code = 'import sys; print(sys._xoptions)' # normally the refcount is hidden rc, out, err = run_python('-c', code) self.assertEqual(out.rstrip(), b'{}') self.assertEqual(err, b'') # "-X showrefcount" shows the refcount, but only in debug builds rc, out, err = run_python('-X', 'showrefcount', '-c', code) self.assertEqual(out.rstrip(), b"{'showrefcount': True}") if hasattr(sys, 'gettotalrefcount'): # debug build self.assertRegex(err, br'^\[\d+ refs, \d+ blocks\]') else: self.assertEqual(err, b'')
Example #7
Source File: test_embed.py From android_universal with MIT License | 5 votes |
def test_pre_initialization_sys_options(self): """ Checks that sys.warnoptions and sys._xoptions can be set before the runtime is initialized (otherwise they won't be effective). """ env = dict(os.environ, PYTHONPATH=os.pathsep.join(sys.path)) out, err = self.run_embedded_interpreter( "pre_initialization_sys_options", env=env) expected_output = ( "sys.warnoptions: ['once', 'module', 'default']\n" "sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}\n" "warnings.filters[:3]: ['default', 'module', 'once']\n" ) self.assertIn(expected_output, out) self.assertEqual(err, '')