evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.07k stars 121 forks source link

1.6.0: pytest is failing #630

Closed kloczek closed 2 years ago

kloczek commented 2 years ago

I'm trying to package your module as an rpm package. So I'm using the typical build, install and test cycle used on building packages from non-root account.

May I ask for help because few units are failing:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) Using --randomly-seed=1522808532 rootdir: /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0 plugins: shutil-1.7.0, virtualenv-1.7.0, mock-3.6.1, cov-2.12.1, anyio-3.3.4, forked-1.3.0, xdist-2.3.0, flaky-3.7.0, tornasync-0.6.0.post2, console-scripts-1.2.0, trio-0.7.0, timeout-2.0.1, asyncio-0.16.0, freezegun-0.4.2, flake8-1.0.7, pyfakefs-4.5.3, hypothesis-6.29.3, benchmark-3.4.1, profiling-1.7.0, datadir-1.3.1, regressions-2.2.0, randomly-3.8.0, rerunfailures-9.1.1 collected 33 items tests/constants_test.py F. [ 6%] tests/main_test.py .. .FFFF.F.FFFF..........FF.F.FF [100%] ================================================================================= FAILURES ================================================================================= ________________________________________________________________________ TestConstants.test_imports ________________________________________________________________________ self = def test_imports(self): for new_imp, (old_imp, ver_cutoff) in constants.py3_to_py2_stdlib.items(): if "/" in old_imp: new_imp, old_imp = new_imp.split(".", 1)[0], old_imp.split("./", 1)[0] if ( # don't test unix-specific dbm.gnu on Windows or PyPy new_imp == "dbm.gnu" and (WINDOWS or PYPY) # don't test ttk on Python 2.6 or PY26 and old_imp == "ttk" # don't test tkinter on PyPy or PYPY and new_imp.startswith("tkinter") # don't test trollius on PyPy or PYPY and old_imp == "trollius" ): pass elif sys.version_info >= ver_cutoff: > assert is_importable(new_imp), "Failed to import " + new_imp E AssertionError: Failed to import dbm.gnu E assert False E + where False = is_importable('dbm.gnu') tests/constants_test.py:99: AssertionError _______________________________________________________________________ TestShell.test_exit_jupyter ________________________________________________________________________ self = def test_exit_jupyter(self): cmd = "coconut --jupyter console" print("\n>", cmd) p = pexpect.spawn(cmd) p.expect("In", timeout=120) p.sendline("exit()") > p.expect("Shutting down kernel|shutting down") tests/main_test.py:642: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.8/site-packages/pexpect/spawnbase.py:343: in expect return self.expect_list(compiled_pattern_list, /usr/lib/python3.8/site-packages/pexpect/spawnbase.py:372: in expect_list return exp.expect_loop(timeout) /usr/lib/python3.8/site-packages/pexpect/expect.py:179: in expect_loop return self.eof(e) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , err = EOF('End Of File (EOF). Exception style platform.') def eof(self, err=None): spawn = self.spawn spawn.before = spawn._before.getvalue() spawn._buffer = spawn.buffer_type() spawn._before = spawn.buffer_type() spawn.after = EOF index = self.searcher.eof_index if index >= 0: spawn.match = EOF spawn.match_index = index return index else: spawn.match = None spawn.match_index = None msg = str(spawn) msg += '\nsearcher: %s' % self.searcher if err is not None: msg = str(err) + '\n' + msg exc = EOF(msg) exc.__cause__ = None # in Python 3.x we can use "raise exc from None" > raise exc E pexpect.exceptions.EOF: End Of File (EOF). Exception style platform. E E command: /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/bin/coconut E args: ['/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/bin/coconut', '--jupyter', 'console'] E buffer (last 100 chars): b'' E before (last 100 chars): b'ubleshoot trust\r\n\r\nJupyter command `jupyter-console` not found.\r\nExiting with error: Jupyter error\r\n' E after: E match: None E match_index: None E exitstatus: None E flag_eof: True E pid: 412925 E child_fd: 15 E closed: False E timeout: 30 E delimiter: E logfile: None E logfile_read: None E logfile_send: None E maxread: 2000 E ignorecase: False E searchwindowsize: None E delaybeforesend: 0.05 E delayafterclose: 0.1 E delayafterterminate: 0.1 E searcher: searcher_re: E 0: re.compile(b'Shutting down kernel|shutting down') /usr/lib/python3.8/site-packages/pexpect/expect.py:122: EOF --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_exit_jupyter... =============================================================================== > coconut --jupyter console ________________________________________________________________________ TestShell.test_import_hook ________________________________________________________________________ name = 'runnable', path = None, target = None > ??? E AttributeError: 'CoconutImporter' object has no attribute 'find_spec' :908: AttributeError During handling of the above exception, another exception occurred: self = def test_import_hook(self): with using_sys_path(src): with using_path(runnable_py): with using_coconut(): auto_compilation(True) > import runnable tests/main_test.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ :991: in _find_and_load ??? :971: in _find_and_load_unlocked ??? :910: in _find_spec ??? :884: in _find_spec_legacy ??? coconut/convenience.py:170: in find_module self.run_compiler(filepath) coconut/convenience.py:153: in run_compiler cmd([path] + list(coconut_import_hook_args)) coconut/convenience.py:50: in cmd return CLI.cmd(args=args, interact=interact) coconut/command/command.py:149: in cmd self.exit_on_error() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def exit_on_error(self): """Exit if exit_code is abnormal.""" if self.exit_code: if self.errmsg is not None: logger.show("Exiting with error: " + self.errmsg) self.errmsg = None if self.using_jobs: kill_children() > sys.exit(self.exit_code) E SystemExit: 1 coconut/command/command.py:166: SystemExit --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_import_hook... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- Traceback (most recent call last): File "", line 908, in _find_spec AttributeError: 'CoconutImporter' object has no attribute 'find_spec' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/command/command.py", line 369, in handling_exceptions yield File "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/command/command.py", line 148, in cmd self.use_args(parsed_args, interact, original_args=args) File "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/command/command.py", line 287, in use_args self.execute(self.comp.parse_block(sys.stdin.read())) File "/usr/lib/python3.8/site-packages/_pytest/capture.py", line 217, in read raise OSError( OSError: pytest: reading from stdin while output is captured! Consider using `-s`. (you should report this at https://github.com/evhub/coconut/issues/new) ___________________________________________________________________________ TestShell.test_code ____________________________________________________________________________ self = def test_code(self): > call(["coconut", "-s", "-c", coconut_snip], assert_output=True) tests/main_test.py:582: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut', '-s', '-c', "msg = ''; pmsg = print$(msg); `pmsg`"], assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut', '-s', '-c', "msg = ''; pmsg = print$(msg); `pmsg`"] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af348e120>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_code... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut -s -c msg = ''; pmsg = print$(msg); `pmsg` 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( _________________________________________________________________________ TestShell.test_runnable __________________________________________________________________________ self = def test_runnable(self): with using_path(runnable_py): > run_runnable() tests/main_test.py:601: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:571: in run_runnable call(["coconut-run"] + args + [runnable_coco, "--arg"], assert_output=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut-run', 'tests/src/runnable.coco', '--arg'], assert_output = ('',), check_mypy = False, check_errors = True, stderr_first = False expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut-run', 'tests/src/runnable.coco', '--arg'], @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af348eba0>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_runnable... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut-run tests/src/runnable.coco --arg 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ___________________________________________________________________________ TestShell.test_pipe ____________________________________________________________________________ self = def test_pipe(self): > call('echo ' + escape(coconut_snip) + "| coconut -s", shell=True, assert_output=True) tests/main_test.py:585: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = 'echo "msg = \'\'; pmsg = print\\$(msg); \\`pmsg\\`"| coconut -s', assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {'shell': True}, cmd = ['echo', '"msg', '=', "'';", 'pmsg', '=', ...] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af3cc5040>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_pipe... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > echo "msg = ''; pmsg = print\$(msg); \`pmsg\`"| coconut -s 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ____________________________________________________________________ TestShell.test_kernel_installation ____________________________________________________________________ self = def test_kernel_installation(self): > call(["coconut", "--jupyter"], assert_output=kernel_installation_msg) tests/main_test.py:628: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut', '--jupyter'], assert_output = ("Coconut: Successfully installed Jupyter kernels: 'coconut', 'coconut_py', 'coconut_py2', 'coconut_py3'",) check_mypy = False, check_errors = True, stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut', '--jupyter'] @py_assert0 = 'Traceback (most recent call last):', @py_assert2 = False @py_format6 = "Traceback in 'Traceback (most recent call last):'\n>assert 'Traceback (... call last):' not in 'Traceback (... call last):'\n~'Traceback (most recent call last):' is contained here:\n~ Traceback (most recent call last):" def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert "Traceback (most recent call last):" not in line, "Traceback in " + repr(line) E AssertionError: Traceback in 'Traceback (most recent call last):' E assert 'Traceback (... call last):' not in 'Traceback (... call last):' E 'Traceback (most recent call last):' is contained here: E Traceback (most recent call last): tests/main_test.py:246: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_kernel_installation... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut --jupyter 1> Coconut: Installing Jupyter kernels 'coconut_py', 'coconut_py2', 'coconut_py3'... 1> Coconut: Successfully installed Jupyter kernels: 'coconut_py', 'coconut_py2', 'coconut_py3' 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> Traceback (most recent call last): 2> File "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/util.py", line 168, in install_custom_kernel 2> os.makedirs(kernel_dest) 2> File "/usr/lib64/python3.8/os.py", line 223, in makedirs 2> mkdir(name, mode) 2> PermissionError: [Errno 13] Permission denied: '/usr/share/jupyter/kernels/coconut' 2> CoconutWarning: Coconut Jupyter kernel installation failed due to above error (try again with 'sudo'). ________________________________________________________________________ TestShell.test_convenience ________________________________________________________________________ self = def test_convenience(self): > call_python(["-c", 'from coconut.convenience import parse; exec(parse("' + coconut_snip + '"))'], assert_output=True) tests/main_test.py:588: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', '-c', 'from coconut.convenience import parse; exec(parse("msg = \'\'; pmsg = print$(msg); `pmsg`"))'] assert_output = ('',), check_mypy = False, check_errors = True, stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {} cmd = ['/usr/bin/python3', '-c', 'from coconut.convenience import parse; exec(parse("msg = \'\'; pmsg = print$(msg); `pmsg`"))'], @py_assert0 = None @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af31d7820>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_convenience... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > /usr/bin/python3 -c from coconut.convenience import parse; exec(parse("msg = ''; pmsg = print$(msg); `pmsg`")) 1> 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( _____________________________________________________________________ TestShell.test_ipython_extension _____________________________________________________________________ self = def test_ipython_extension(self): > call( ["ipython", "--ext", "coconut", "-c", r'%coconut ' + coconut_snip], assert_output=(True,) + (("Jupyter error",) if WINDOWS else ()), stderr_first=WINDOWS, check_errors=not WINDOWS, expect_retcode=0 if not WINDOWS else None, ) tests/main_test.py:619: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['ipython', '--ext', 'coconut', '-c', "%coconut msg = ''; pmsg = print$(msg); `pmsg`"], assert_output = ('',), check_mypy = False check_errors = True, stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {} cmd = ['ipython', '--ext', 'coconut', '-c', "%coconut msg = ''; pmsg = print$(msg); `pmsg`"], @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '\x1b[22;0t\x1b]0;IPython: BUILD/coconut-1.6.0\x07' E "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af3363c10>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_ipython_extension... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > ipython --ext coconut -c %coconut msg = ''; pmsg = print$(msg); `pmsg` 1> 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( _____________________________________________________________________ TestShell.test_runnable_nowrite ______________________________________________________________________ self = def test_runnable_nowrite(self): > run_runnable(["-n"]) tests/main_test.py:604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:571: in run_runnable call(["coconut-run"] + args + [runnable_coco, "--arg"], assert_output=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut-run', '-n', 'tests/src/runnable.coco', '--arg'], assert_output = ('',), check_mypy = False, check_errors = True, stderr_first = False expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut-run', '-n', 'tests/src/runnable.coco', '--arg'], @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af394b040>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_runnable_nowrite... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut-run -n tests/src/runnable.coco --arg 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ___________________________________________________________ TestCompilation.test_simple_line_numbers_keep_lines ____________________________________________________________ self = def test_simple_line_numbers_keep_lines(self): > run_runnable(["-n", "--line-numbers", "--keep-lines"]) tests/main_test.py:715: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:571: in run_runnable call(["coconut-run"] + args + [runnable_coco, "--arg"], assert_output=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut-run', '-n', '--line-numbers', '--keep-lines', 'tests/src/runnable.coco', '--arg'], assert_output = ('',), check_mypy = False check_errors = True, stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {} cmd = ['coconut-run', '-n', '--line-numbers', '--keep-lines', 'tests/src/runnable.coco', '--arg'], @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af394b7b0>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_simple_line_numbers_keep_lines... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut-run -n --line-numbers --keep-lines tests/src/runnable.coco --arg 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( _________________________________________________________________________ TestCompilation.test_run _________________________________________________________________________ self = def test_run(self): > run(use_run_arg=True) tests/main_test.py:705: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:496: in run comp_runner(["--run"] + agnostic_args, **_kwargs) tests/main_test.py:422: in comp_runner comp(file="runner.coco", args=args, **kwargs) tests/main_test.py:303: in comp call_coconut([source, compdest] + args, **kwargs) tests/main_test.py:285: in call_coconut call_python(["-m", "coconut"] + args, **kwargs) tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', 'tests/src/runner.coco', ...], assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', 'tests/src/runner.coco', ...] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E 'Compiling tests/src/runner.coco ...' E 'Compiled to tests/dest/runner.py .' E '.........' E '' E "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af3591ba0>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_run... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_3 tests/dest/cocotest --target 3 1> Compiling tests/src/cocotest/target_3/py3_test.coco ... 1> Compiled to tests/dest/cocotest/py3_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_35 tests/dest/cocotest --target 35 1> Compiling tests/src/cocotest/target_35/py35_test.coco ... 1> Compiled to tests/dest/cocotest/py35_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_36 tests/dest/cocotest --target 36 1> Compiling tests/src/cocotest/target_36/py36_test.coco ... 1> Compiled to tests/dest/cocotest/py36_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/agnostic tests/dest/cocotest 1> Compiling tests/src/cocotest/agnostic/__init__.coco ... 1> Compiling tests/src/cocotest/agnostic/main.coco ... 1> Compiling tests/src/cocotest/agnostic/specific.coco ... 1> Compiling tests/src/cocotest/agnostic/suite.coco ... 1> Compiling tests/src/cocotest/agnostic/tutorial.coco ... 1> Compiling tests/src/cocotest/agnostic/util.coco ... 1> Compiled to tests/dest/cocotest/__init__.py . 1> Compiled to tests/dest/cocotest/specific.py . 1> Compiled to tests/dest/cocotest/tutorial.py . 1> Compiled to tests/dest/cocotest/suite.py . 1> Compiled to tests/dest/cocotest/main.py . 1> Compiled to tests/dest/cocotest/util.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 893) 2> import * # type: ignore 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 897) 2> from * import * # type: ignore > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_sys tests/dest/cocotest --target sys 1> Compiling tests/src/cocotest/target_sys/target_sys_test.coco ... 1> Compiled to tests/dest/cocotest/target_sys_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/non_strict tests/dest/cocotest 1> Compiling tests/src/cocotest/non_strict/non_strict_test.coco ... 1> Compiled to tests/dest/cocotest/non_strict_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: unnecessary from __future__ import (Coconut does these automatically) (line 1) 2> from __future__ import division 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 22) 2> case {"a": a}: 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be class match or data match (resolving to Python-style class match due to Python-style "match: case" block) (use explicit 'data data_name(patterns)' or 'class cls_name(patterns)' syntax to dismiss) (line 32) 2> case A(x=1): 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 44) 2> case {"a": a}: 2> ^ > /usr/bin/python3 -m coconut --jobs sys tests/src/runner.coco tests/dest --run 1> Compiling tests/src/runner.coco ... 1> Compiled to tests/dest/runner.py . 1> ......... 1> 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ____________________________________________________________________ TestCompilation.test_simple_minify ____________________________________________________________________ self = def test_simple_minify(self): > run_runnable(["-n", "--minify"]) tests/main_test.py:718: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:571: in run_runnable call(["coconut-run"] + args + [runnable_coco, "--arg"], assert_output=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut-run', '-n', '--minify', 'tests/src/runnable.coco', '--arg'], assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut-run', '-n', '--minify', 'tests/src/runnable.coco', '--arg'] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af35834a0>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_simple_minify... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut-run -n --minify tests/src/runnable.coco --arg 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( __________________________________________________________________ TestCompilation.test_simple_keep_lines __________________________________________________________________ self = def test_simple_keep_lines(self): > run_runnable(["-n", "--keep-lines"]) tests/main_test.py:712: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:571: in run_runnable call(["coconut-run"] + args + [runnable_coco, "--arg"], assert_output=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut-run', '-n', '--keep-lines', 'tests/src/runnable.coco', '--arg'], assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut-run', '-n', '--keep-lines', 'tests/src/runnable.coco', '--arg'] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f4af3583c10>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_simple_keep_lines... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut-run -n --keep-lines tests/src/runnable.coco --arg 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ______________________________________________________________________ TestCompilation.test_mypy_sys _______________________________________________________________________ self = def test_mypy_sys(self): > run(["--mypy"] + mypy_args, agnostic_target="sys", expect_retcode=None, check_errors=False) # fails due to tutorial mypy errors tests/main_test.py:682: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:491: in run comp_non_strict(args, **kwargs) tests/main_test.py:458: in comp_non_strict comp(path="cocotest", folder="non_strict", args=non_strict_args, **kwargs) tests/main_test.py:303: in comp call_coconut([source, compdest] + args, **kwargs) tests/main_test.py:285: in call_coconut call_python(["-m", "coconut"] + args, **kwargs) tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', 'tests/src/cocotest/non_strict', ...], assert_output = ('',), check_mypy = True, check_errors = False stderr_first = False, expect_retcode = None, convert_to_import = False, kwargs = {} cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', 'tests/src/cocotest/non_strict', ...], @py_assert0 = 'error:', @py_assert2 = False @py_format6 = "MyPy error in '/home/tkloczko/.coconut_stubs/__coconut__.pyi:229: error: Library stubs not'\n>assert 'error:' not in '/home/tkloc...ry stubs not'\n~'error:' is contained here:\n~ .pyi:229: error: Library stubs not\n~? ++++++" def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert "error:" not in line, "MyPy error in " + repr(line) E AssertionError: MyPy error in '/home/tkloczko/.coconut_stubs/__coconut__.pyi:229: error: Library stubs not' E assert 'error:' not in '/home/tkloc...ry stubs not' E 'error:' is contained here: E .pyi:229: error: Library stubs not E ? ++++++ tests/main_test.py:250: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_mypy_sys... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_3 tests/dest/cocotest --target 3 --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/target_3/py3_test.coco ... 1> Compiled to tests/dest/cocotest/py3_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_35 tests/dest/cocotest --target 35 --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/target_35/py35_test.coco ... 1> Compiled to tests/dest/cocotest/py35_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_36 tests/dest/cocotest --target 36 --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/target_36/py36_test.coco ... 1> Compiled to tests/dest/cocotest/py36_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/agnostic tests/dest/cocotest --target sys --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/agnostic/__init__.coco ... 1> Compiling tests/src/cocotest/agnostic/main.coco ... 1> Compiling tests/src/cocotest/agnostic/specific.coco ... 1> Compiling tests/src/cocotest/agnostic/suite.coco ... 1> Compiling tests/src/cocotest/agnostic/tutorial.coco ... 1> Compiling tests/src/cocotest/agnostic/util.coco ... 1> Compiled to tests/dest/cocotest/__init__.py . 1> Compiled to tests/dest/cocotest/specific.py . 1> Compiled to tests/dest/cocotest/tutorial.py . 1> Compiled to tests/dest/cocotest/suite.py . 1> Compiled to tests/dest/cocotest/main.py . 1> Compiled to tests/dest/cocotest/util.py . 1> Exiting with error: MyPy error 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 893) 2> import * # type: ignore 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 897) 2> from * import * # type: ignore 2> tests/dest/cocotest/tutorial.py:62: error: Name "factorial" already defined on 2> line 36 2> def factorial(n): #27 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:101: error: Name "factorial" already defined on 2> line 36 2> def factorial(n): #53 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:156: error: Name "factorial" already defined on 2> line 36 2> def factorial(n): #90 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:190: error: Name "factorial" already defined on 2> line 36 2> @_coconut_tco #116 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:238: error: Name "factorial" already defined on 2> line 36 2> @_coconut_tco #142 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:273: error: Name "factorial" already defined on 2> line 36 2> @_coconut_mark_as_match #168 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:285: error: Name "factorial" already defined on 2> line 273 2> @_coconut_addpattern(factorial) #170 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:324: error: Name "factorial" already defined on 2> line 36 2> @_coconut_mark_as_match #190 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:336: error: Name "factorial" already defined on 2> line 324 2> @_coconut_addpattern(factorial) #192 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:386: error: Name "quick_sort" already defined 2> on line 374 2> @_coconut_addpattern(quick_sort) #214 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:415: error: Name "quick_sort" already defined 2> on line 374 2> def quick_sort(l): #227 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:462: error: Property "x" defined in 2> "vector2@443" is read-only 2> v.x = 7 #255 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:494: error: Name "__new__" already defined on 2> line 477 2> @_coconut_tco #263 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:515: error: Name "vector" already defined on 2> line 468 2> class vector(_coconut.collections.namedtuple("vector", ('pts',))): #2... 2> ^ 2> tests/dest/cocotest/tutorial.py:541: error: Name "__new__" already defined on 2> line 524 2> @_coconut_tco #276 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:639: error: Argument 1 to "abs" has 2> incompatible type "vector"; expected "SupportsAbs[]" 2> assert (abs)(vector(3, 4)) == 5 #310 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:641: error: Unsupported left operand type for - 2> ("vector") 2> assert (str)(vector(2, 2) - vector(0, 1)) == "vector(*pts=(2, 1))" #3... 2> ^ 2> tests/dest/cocotest/tutorial.py:642: error: Unsupported operand type for unary 2> - ("vector") 2> assert (str)(-vector(1, 3)) == "vector(*pts=(-1, -3))" #313 (line num... 2> ^ 2> tests/dest/cocotest/tutorial.py:647: error: Unsupported operand types for * 2> ("vector" and "vector") 2> assert vector(1, 2) * vector(1, 3) == 7 #318 (line num in coconut sou... 2> ^ 2> tests/dest/cocotest/tutorial.py:675: error: Name "vector" already defined on 2> line 468 2> class vector(_coconut.collections.namedtuple("vector", ('pts',))): #3... 2> ^ 2> tests/dest/cocotest/tutorial.py:701: error: Name "__new__" already defined on 2> line 684 2> @_coconut_tco #342 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:796: error: Name "diagonal_line" already 2> defined on line 649 2> @_coconut_tco #373 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:799: error: Name "linearized_plane" already 2> defined on line 657 2> @_coconut_tco #374 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:802: error: Name "vector_field" already defined 2> on line 667 2> @_coconut_tco #375 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:817: error: Name "vector" already defined on 2> line 468 2> class vector(_coconut.collections.namedtuple("vector", ('pts',))): #3... 2> ^ 2> tests/dest/cocotest/tutorial.py:843: error: Name "__new__" already defined on 2> line 826 2> @_coconut_tco #390 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/tutorial.py:968: error: Unsupported operand types for / 2> ("vector" and "int") 2> assert (str)(vector(3, 4) / 1) == "vector(*pts=(3.0, 4.0))" #426 (lin... 2> ^ 2> tests/dest/cocotest/tutorial.py:969: error: Unsupported operand types for / 2> ("vector" and "int") 2> assert (str)(vector(2, 4) / 2) == "vector(*pts=(1.0, 2.0))" #427 (lin... 2> ^ 2> tests/dest/cocotest/tutorial.py:970: error: "vector" has no attribute "unit" 2> assert (str)(vector(0, 1).unit()) == "vector(*pts=(0.0, 1.0))" #428 (... 2> ^ 2> tests/dest/cocotest/tutorial.py:971: error: "vector" has no attribute "unit" 2> assert (str)(vector(5, 0).unit()) == "vector(*pts=(1.0, 0.0))" #429 (... 2> ^ 2> tests/dest/cocotest/tutorial.py:972: error: "vector" has no attribute "angle" 2> assert vector(2, 0).angle(vector(3, 0)) == 0.0 #430 (line num in coco... 2> ^ 2> tests/dest/cocotest/tutorial.py:973: error: "vector" has no attribute "angle" 2> assert vector(1, 0).angle(vector(0, 2)) == math.pi / 2 #431 (line num... 2> ^ 2> tests/dest/cocotest/tutorial.py:975: error: "vector" has no attribute "angle" 2> vector(1, 2).angle(5) #433 (line num in coconut source) 2> ^ 2> tests/dest/cocotest/main.py:2070: note: Revealed type is "def [_Tco, _Uco] (func: def (_Tco`-1) -> _Uco`-2, obj: typing.Iterable[_Tco`-1]) -> typing.Iterable[_Uco`-2]" 2> tests/dest/cocotest/main.py:2072: note: Revealed local types are: 2> tests/dest/cocotest/main.py:2072: note: x: builtins.int 2> Found 33 errors in 1 file (checked 6 source files) > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_sys tests/dest/cocotest --target sys --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/target_sys/target_sys_test.coco ... 1> Compiled to tests/dest/cocotest/target_sys_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/non_strict tests/dest/cocotest --mypy --follow-imports silent --ignore-missing-imports --allow-redefinition 1> Compiling tests/src/cocotest/non_strict/non_strict_test.coco ... 1> Compiled to tests/dest/cocotest/non_strict_test.py . 1> Exiting with error: MyPy error 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: unnecessary from __future__ import (Coconut does these automatically) (line 1) 2> from __future__ import division 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 22) 2> case {"a": a}: 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be class match or data match (resolving to Python-style class match due to Python-style "match: case" block) (use explicit 'data data_name(patterns)' or 'class cls_name(patterns)' syntax to dismiss) (line 32) 2> case A(x=1): 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 44) 2> case {"a": a}: 2> ^ 2> /home/tkloczko/.coconut_stubs/__coconut__.pyi:229: error: Library stubs not 2> installed for "backports.functools_lru_cache" (or incompatible with Python 2.7) 2> from backports.functools_lru_cache import lru_cache as _lru_cache ... 2> ^ 2> /home/tkloczko/.coconut_stubs/__coconut__.pyi:229: note: Hint: "python3 -m pip install types-backports" 2> /home/tkloczko/.coconut_stubs/__coconut__.pyi:229: note: (or run "mypy --install-types" to install all missing stub packages) 2> /home/tkloczko/.coconut_stubs/__coconut__.pyi:229: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports 2> Found 1 error in 1 file (checked 1 source file) ============================================================================= warnings summary ============================================================================= coconut/_pyparsing.py:97 /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) warn( -- Docs: https://docs.pytest.org/en/stable/warnings.html ========================================================================= short test summary info ========================================================================== FAILED tests/constants_test.py::TestConstants::test_imports - AssertionError: Failed to import dbm.gnu FAILED tests/main_test.py::TestShell::test_exit_jupyter - pexpect.exceptions.EOF: End Of File (EOF). Exception style platform. FAILED tests/main_test.py::TestShell::test_import_hook - SystemExit: 1 FAILED tests/main_test.py::TestShell::test_code - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_runnable - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_pipe - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_kernel_installation - AssertionError: Traceback in 'Traceback (most recent call last):' FAILED tests/main_test.py::TestShell::test_convenience - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_ipython_extension - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_runnable_nowrite - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_line_numbers_keep_lines - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_run - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_minify - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_keep_lines - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_mypy_sys - AssertionError: MyPy error in '/home/tkloczko/.coconut_stubs/__coconut__.pyi:229: error: Library stubs not' ========================================================== 15 failed, 18 passed, 1 warning in 1559.01s (0:25:59) =========================================================== ```
evhub commented 2 years ago

@kloczek Those tests are really not meant to be run outside of Coconut's continuous integration runs, especially since they take a lot of time to run (running the whole test suite can take almost an hour). Why do you need to run tests at install time?

kloczek commented 2 years ago

It does not matter how long those test are running. I'm running test suite on buildng rpm packages.

So why those units are failing? :)

evhub commented 2 years ago

@kloczek Well, if you want to get them to succeed, you're going to have to follow the same pipeline that Coconut's continuous integration tests use, which means running make install test-all.

kloczek commented 2 years ago

Looking on what is in CI looks like you are not using pytest. Am I ringht?

BTW pytest shows some warnings

============================================================================= warnings summary =============================================================================
coconut/_pyparsing.py:97
  /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)
    warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
kloczek commented 2 years ago

In meantime I've moved to pep517 based build and updated many packages in my env. Now I'm notising that coconut test suite warns about to high versions of some modules (pyparsing/cPyparsing). Do you have any plans to update coconut to be able iuse it with freshen pyparsing?

```consile .fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0 collected 33 items tests/constants_test.py .F [ 6%] tests/main_test.py F.FFF.FFFFF FFFFF.FFFFFFFF.FFF.. [100%] ================================================================================= FAILURES ================================================================================= ________________________________________________________________________ TestConstants.test_imports ________________________________________________________________________ self = def test_imports(self): for new_imp, (old_imp, ver_cutoff) in constants.py3_to_py2_stdlib.items(): if "/" in old_imp: new_imp, old_imp = new_imp.split(".", 1)[0], old_imp.split("./", 1)[0] if ( # don't test unix-specific dbm.gnu on Windows or PyPy new_imp == "dbm.gnu" and (WINDOWS or PYPY) # don't test ttk on Python 2.6 or PY26 and old_imp == "ttk" # don't test tkinter on PyPy or PYPY and new_imp.startswith("tkinter") # don't test trollius on PyPy or PYPY and old_imp == "trollius" ): pass elif sys.version_info >= ver_cutoff: > assert is_importable(new_imp), "Failed to import " + new_imp E AssertionError: Failed to import dbm.gnu E assert False E + where False = is_importable('dbm.gnu') tests/constants_test.py:99: AssertionError ___________________________________________________________________________ TestShell.test_code ____________________________________________________________________________ self = def test_code(self): > call(["coconut", "-s", "-c", coconut_snip], assert_output=True) tests/main_test.py:582: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut', '-s', '-c', "msg = ''; pmsg = print$(msg); `pmsg`"], assert_output = ('',), check_mypy = False, check_errors = True stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut', '-s', '-c', "msg = ''; pmsg = print$(msg); `pmsg`"] @py_assert0 = None, @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f56e2637900>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_code... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut -s -c msg = ''; pmsg = print$(msg); `pmsg` 1> 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( ________________________________________________________________________ TestShell.test_convenience ________________________________________________________________________ self = def test_convenience(self): > call_python(["-c", 'from coconut.convenience import parse; exec(parse("' + coconut_snip + '"))'], assert_output=True) tests/main_test.py:588: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', '-c', 'from coconut.convenience import parse; exec(parse("msg = \'\'; pmsg = print$(msg); `pmsg`"))'] assert_output = ('',), check_mypy = False, check_errors = True, stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {} cmd = ['/usr/bin/python3', '-c', 'from coconut.convenience import parse; exec(parse("msg = \'\'; pmsg = print$(msg); `pmsg`"))'], @py_assert0 = None @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected ''; got: E '' E "/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E assert False E + where False = any(. at 0x7f56e26097b0>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestShell.test_convenience... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > /usr/bin/python3 -c from coconut.convenience import parse; exec(parse("msg = ''; pmsg = print$(msg); `pmsg`")) 1> 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( [..] _______________________________________________________________________ TestCompilation.test_target ________________________________________________________________________ self = def test_target(self): > run(agnostic_target=(2 if PY2 else 3)) tests/main_test.py:685: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:509: in run run_extras(convert_to_import=convert_to_import) # **kwargs are for comp, not run tests/main_test.py:468: in run_extras call_python([os.path.join(dest, "extras.py")], assert_output=True, check_errors=False, stderr_first=True, **kwargs) tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', 'tests/dest/extras.py'], assert_output = ('',), check_mypy = False, check_errors = False, stderr_first = True, expect_retcode = 0 convert_to_import = False, kwargs = {}, cmd = ['/usr/bin/python3', 'tests/dest/extras.py'] def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: > assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) E AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] E assert 1 == 0 tests/main_test.py:200: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_target... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_3 tests/dest/cocotest --target 3 1> Compiling tests/src/cocotest/target_3/py3_test.coco ... 1> Compiled to tests/dest/cocotest/py3_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_35 tests/dest/cocotest --target 35 1> Compiling tests/src/cocotest/target_35/py35_test.coco ... 1> Compiled to tests/dest/cocotest/py35_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_36 tests/dest/cocotest --target 36 1> Compiling tests/src/cocotest/target_36/py36_test.coco ... 1> Compiled to tests/dest/cocotest/py36_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/agnostic tests/dest/cocotest --target 3 1> Compiling tests/src/cocotest/agnostic/__init__.coco ... 1> Compiling tests/src/cocotest/agnostic/main.coco ... 1> Compiling tests/src/cocotest/agnostic/specific.coco ... 1> Compiling tests/src/cocotest/agnostic/suite.coco ... 1> Compiling tests/src/cocotest/agnostic/tutorial.coco ... 1> Compiling tests/src/cocotest/agnostic/util.coco ... 1> Compiled to tests/dest/cocotest/__init__.py . 1> Compiled to tests/dest/cocotest/specific.py . 1> Compiled to tests/dest/cocotest/tutorial.py . 1> Compiled to tests/dest/cocotest/suite.py . 1> Compiled to tests/dest/cocotest/main.py . 1> Compiled to tests/dest/cocotest/util.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 893) 2> import * # type: ignore 2> in tests/src/cocotest/agnostic/main.coco: 2> CoconutSyntaxWarning: [from *] import * is a Coconut Easter egg and should not be used in production code (line 897) 2> from * import * # type: ignore > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/target_sys tests/dest/cocotest --target sys 1> Compiling tests/src/cocotest/target_sys/target_sys_test.coco ... 1> Compiled to tests/dest/cocotest/target_sys_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 -m coconut --jobs sys tests/src/cocotest/non_strict tests/dest/cocotest 1> Compiling tests/src/cocotest/non_strict/non_strict_test.coco ... 1> Compiled to tests/dest/cocotest/non_strict_test.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: unnecessary from __future__ import (Coconut does these automatically) (line 1) 2> from __future__ import division 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 22) 2> case {"a": a}: 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be class match or data match (resolving to Python-style class match due to Python-style "match: case" block) (use explicit 'data data_name(patterns)' or 'class cls_name(patterns)' syntax to dismiss) (line 32) 2> case A(x=1): 2> ^ 2> in tests/src/cocotest/non_strict/non_strict_test.coco: 2> CoconutSyntaxWarning: ambiguous pattern; could be Coconut-style len-checking dict match or Python-style len-ignoring dict match (resolving to Python-style len-ignoring dict match due to Python-style "match: case" block) (use explicit '{..., **_}' or '{..., **{}}' syntax to dismiss) (line 44) 2> case {"a": a}: 2> ^ > /usr/bin/python3 -m coconut --jobs sys tests/src/runner.coco tests/dest --target 3 1> Compiling tests/src/runner.coco ... 1> Compiled to tests/dest/runner.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 tests/dest/runner.py 1> ......... 1> > /usr/bin/python3 -m coconut --jobs sys tests/src/extras.coco tests/dest --target 3 1> Compiling tests/src/extras.coco ... 1> Compiled to tests/dest/extras.py . 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( > /usr/bin/python3 tests/dest/extras.py 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> Traceback (most recent call last): 2> File "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/icoconut/root.py", line 62, in 2> from ipykernel.ipkernel import IPythonKernel 2> ModuleNotFoundError: No module named 'ipykernel' 2> 2> During handling of the above exception, another exception occurred: 2> 2> Traceback (most recent call last): 2> File "tests/dest/extras.py", line 1002, in 2> from coconut.icoconut import CoconutKernel # type: ignore 2> File "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/icoconut/__init__.py", line 20, in 2> from coconut.icoconut.root import * # NOQA 2> File "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/icoconut/root.py", line 71, in 2> raise CoconutException( 2> coconut.exceptions.CoconutException: --jupyter flag requires Jupyter library (run '/usr/bin/python3 -m pip install coconut[jupyter]' to fix) _________________________________________________________________ TestCompilation.test_universal_mypy_snip _________________________________________________________________ self = def test_universal_mypy_snip(self): > call( ["coconut", "-c", mypy_snip, "--mypy"], assert_output=mypy_snip_err_2, check_errors=False, check_mypy=False, ) tests/main_test.py:658: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['coconut', '-c', 'a: str = count()[0]', '--mypy'] assert_output = ('error: Incompatible types in assignment (expression has type "int", variable has type "unicode")',), check_mypy = False, check_errors = False stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {}, cmd = ['coconut', '-c', 'a: str = count()[0]', '--mypy'], @py_assert0 = None @py_assert2 = None def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) if stderr_first: out = stderr + stdout else: out = stdout + stderr out = "".join(out) raw_lines = out.splitlines() lines = [] i = 0 while True: if i >= len(raw_lines): break line = raw_lines[i] # ignore https://bugs.python.org/issue39098 errors if sys.version_info < (3, 9) and line == "Error in atexit._run_exitfuncs:": while True: i += 1 if i >= len(raw_lines): break new_line = raw_lines[i] if not new_line.startswith(" ") and not any(test in new_line for test in ignore_atexit_errors_with): i -= 1 break continue # combine mypy error lines if line.rstrip().endswith("error:"): line += raw_lines[i + 1] i += 1 lines.append(line) i += 1 for line in lines: assert "CoconutInternalException" not in line, "CoconutInternalException in " + repr(line) assert " assert any(x in last_line for x in assert_output), ( "Expected " + ", ".join(repr(s) for s in assert_output) + "; got:\n" + "\n".join(repr(li) for li in raw_lines) ) E AssertionError: Expected 'error: Incompatible types in assignment (expression has type "int", variable has type "unicode")'; got: E "/home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix)" E ' warn(' E 'The typed_ast package is not installed.' E 'For Python 2 support, install mypy using `python3 -m pip install "mypy[python2]"`Alternatively, you can install typed_ast with `python3 -m pip install typed-ast`.' E 'The typed_ast package is not installed.' E 'For Python 2 support, install mypy using `python3 -m pip install "mypy[python2]"`Alternatively, you can install typed_ast with `python3 -m pip install typed-ast`.' E assert False E + where False = any(. at 0x7f56e1a4af90>) tests/main_test.py:265: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestCompilation.test_universal_mypy_snip... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > coconut -c a: str = count()[0] --mypy 2> /home/tkloczko/rpmbuild/BUILDROOT/python-coconut-1.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> The typed_ast package is not installed. 2> For Python 2 support, install mypy using `python3 -m pip install "mypy[python2]"`Alternatively, you can install typed_ast with `python3 -m pip install typed-ast`. 2> The typed_ast package is not installed. 2> For Python 2 support, install mypy using `python3 -m pip install "mypy[python2]"`Alternatively, you can install typed_ast with `python3 -m pip install typed-ast`. ________________________________________________________________________ TestExternal.test_prelude _________________________________________________________________________ self = def test_prelude(self): with using_path(prelude): > comp_prelude() tests/main_test.py:732: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/main_test.py:542: in comp_prelude call_coconut([os.path.join(prelude, "setup.coco"), "--strict"] + args, **kwargs) tests/main_test.py:285: in call_coconut call_python(["-m", "coconut"] + args, **kwargs) tests/main_test.py:273: in call_python call([sys.executable] + args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ raw_cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', './coconut-prelude/setup.coco', ...], assert_output = ('',), check_mypy = True, check_errors = False stderr_first = False, expect_retcode = 0, convert_to_import = False, kwargs = {} cmd = ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', './coconut-prelude/setup.coco', ...] def call(raw_cmd, assert_output=False, check_mypy=False, check_errors=True, stderr_first=False, expect_retcode=0, convert_to_import=False, **kwargs): """Execute a shell command and assert that no errors were encountered.""" if isinstance(raw_cmd, str): cmd = raw_cmd.split() else: cmd = raw_cmd print() logger.log_cmd(cmd) if assert_output is False: assert_output = ("",) elif assert_output is True: assert_output = ("",) elif isinstance(assert_output, str): if "\n" not in assert_output: assert_output = (assert_output,) else: assert_output = tuple(x if x is not True else "" for x in assert_output) if convert_to_import is None: convert_to_import = ( cmd[0] == sys.executable and cmd[1] != "-c" and cmd[1:3] != ["-m", "coconut"] ) if convert_to_import: assert cmd[0] == sys.executable if cmd[1] == "-m": module_name = cmd[2] extra_argv = cmd[3:] stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: module_path = cmd[1] extra_argv = cmd[2:] module_dir = os.path.dirname(module_path) module_name = os.path.splitext(os.path.basename(module_path))[0] if os.path.isdir(module_path): module_name += ".__main__" with using_sys_path(module_dir): stdout, stderr, retcode = call_with_import(module_name, extra_argv) else: stdout, stderr, retcode = call_output(raw_cmd, **kwargs) if expect_retcode is not None: > assert retcode == expect_retcode, "Return code not as expected ({retcode} != {expect_retcode}) in: {cmd!r}".format( retcode=retcode, expect_retcode=expect_retcode, cmd=raw_cmd, ) E AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', './coconut-prelude/setup.coco', '--strict', '--target', '3.6', '--mypy'] E assert 1 == 0 tests/main_test.py:200: AssertionError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- =============================================================================== running TestExternal.test_prelude... =============================================================================== --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- > git clone https://github.com/evhub/coconut-prelude 2> Cloning into 'coconut-prelude'... > /usr/bin/python3 -m coconut --jobs sys ./coconut-prelude/setup.coco --strict --target 3.6 --mypy 1> Compiling coconut-prelude/setup.coco ... 1> Compiled to coconut-prelude/setup.py . 1> Exiting with error: MyPy error 2> /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) 2> warn( 2> CoconutWarning: missing __init__.coco in package: '/home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut-prelude' (remove --strict to dismiss) 2> coconut-prelude/setup.py:13: error: Value of type variable "AnyStr" of 2> "dirname" cannot be "Optional[str]" 2> if _coconut_cached_module is not None and _coconut_os.path.dirname(_co... 2> ^ 2> Found 1 error in 1 file (checked 1 source file) 2> :7: error: Value of type variable "AnyStr" of "dirname" cannot be 2> "Optional[str]" 2> CoconutWarning: missing psutil; --jobs may not properly terminate (run '/usr/bin/python3 -m pip install coconut[jobs]' to fix) ============================================================================= warnings summary ============================================================================= coconut/_pyparsing.py:97 /home/tkloczko/rpmbuild/BUILD/coconut-1.6.0/coconut/_pyparsing.py:97: UserWarning: This version of Coconut was built for pyparsing/cPyparsing versions < 2.4.8; got Python pyparsing v3.0.6 (run '/usr/bin/python3 -m pip install pyparsing<2.4.8' to fix) warn( -- Docs: https://docs.pytest.org/en/stable/warnings.html ========================================================================= short test summary info ========================================================================== FAILED tests/constants_test.py::TestConstants::test_imports - AssertionError: Failed to import dbm.gnu FAILED tests/main_test.py::TestShell::test_code - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_convenience - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_exit_jupyter - pexpect.exceptions.EOF: End Of File (EOF). Exception style platform. FAILED tests/main_test.py::TestShell::test_import_hook - SystemExit: 1 FAILED tests/main_test.py::TestShell::test_ipython_extension - FileNotFoundError: [Errno 2] No such file or directory: 'ipython' FAILED tests/main_test.py::TestShell::test_kernel_installation - AssertionError: Return code not as expected (1 != 0) in: ['coconut', '--jupyter'] FAILED tests/main_test.py::TestShell::test_pipe - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_runnable - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestShell::test_runnable_nowrite - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_and - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_jobs_zero - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_line_numbers - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_mypy_sys - AssertionError: MyPy error in 'tests/dest/cocotest/py3_test.py:12: error: Value of type variable "AnyStr" of' FAILED tests/main_test.py::TestCompilation::test_no_tco - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_normal - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_package - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_run - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_keep_lines - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_line_numbers_keep_lines - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_simple_minify - AssertionError: Expected ''; got: FAILED tests/main_test.py::TestCompilation::test_standalone - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_strict - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_target - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', 'tests/dest/extras.py'] FAILED tests/main_test.py::TestCompilation::test_universal_mypy_snip - AssertionError: Expected 'error: Incompatible types in assignment (expression has type "int", vari... FAILED tests/main_test.py::TestExternal::test_prelude - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', '-m', 'coconut', '--jobs', 'sys', '... =========================================================== 26 failed, 7 passed, 1 warning in 1275.62s (0:21:15) =========================================================== ```
evhub commented 2 years ago

No, there are no plans to update Coconut to pyparsing>=3. There are not really any benefits to updating Coconut to the newest pyparsing, since Coconut should whenever possible be run on cPyparsing rather than pyparsing anyway.

kloczek commented 2 years ago

Just tested 2.0.0 with cpyparsing 2.4.7.1.1.0 and pytest still is failing

========================================================================= short test summary info ==========================================================================
FAILED coconut/tests/constants_test.py::TestConstants::test_imports - AssertionError: Failed to import dbm.gnu
FAILED coconut/tests/main_test.py::TestShell::test_code - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_compile_runnable - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_convenience - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_exit_jupyter - pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
FAILED coconut/tests/main_test.py::TestShell::test_import_hook - SystemExit: 1
FAILED coconut/tests/main_test.py::TestShell::test_import_runnable - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_ipython_extension - FileNotFoundError: [Errno 2] No such file or directory: 'ipython'
FAILED coconut/tests/main_test.py::TestShell::test_kernel_installation - AssertionError: Return code not as expected (1 != 0) in: ['coconut', '--jupyter']
FAILED coconut/tests/main_test.py::TestShell::test_pipe - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_runnable - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestShell::test_runnable_nowrite - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_and - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_jobs_zero - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_line_numbers - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_mypy_sys - AssertionError: MyPy error in 'coconut/tests/dest/cocotest/py3_test.py:30: error: Module "__coconut__...
FAILED coconut/tests/main_test.py::TestCompilation::test_no_tco - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_no_wrap_mypy_snip - IndexError: list index out of range
FAILED coconut/tests/main_test.py::TestCompilation::test_normal - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_package - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_run - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_simple_keep_lines - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_simple_line_numbers_keep_lines - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_simple_minify - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_standalone - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_strict - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_sys_mypy_snip - IndexError: list index out of range
FAILED coconut/tests/main_test.py::TestCompilation::test_target - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestCompilation::test_universal_mypy_snip - IndexError: list index out of range
FAILED coconut/tests/main_test.py::TestExternal::test_bbopt - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestExternal::test_prelude - AssertionError: Return code not as expected (1 != 0) in: ['/usr/bin/python3', '-m', 'coconut', '--jobs', ...
FAILED coconut/tests/main_test.py::TestExternal::test_pyprover - AssertionError: Traceback in 'Traceback (most recent call last):'
FAILED coconut/tests/main_test.py::TestExternal::test_pyston - AssertionError: Traceback in 'Traceback (most recent call last):'
================================================================= 33 failed, 3 passed in 248.90s (0:04:08) =================================================================
evhub commented 2 years ago

Yes, like I said, Coconut's tests are not meant to be run by the end user and will only succeed if you copy Coconut's testing pipeline exactly.