Merge pull request #1000 from skirpichev/wa-996
Workaround support for multiple statements in CLI
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ del ip
|
||||
source += "\n"
|
||||
|
||||
try:
|
||||
code = self.compile(source, filename, symbol)
|
||||
code = self.compile(source, filename, 'exec')
|
||||
except (OverflowError, SyntaxError, ValueError):
|
||||
if sys.version_info >= (3, 13):
|
||||
self.showsyntaxerror(filename, source=source)
|
||||
|
||||
@@ -17,9 +17,13 @@ if platform.python_implementation() == 'PyPy':
|
||||
class Console(pexpect.spawn):
|
||||
"""Spawned console for testing."""
|
||||
|
||||
def __init__(self, command, timeout=60):
|
||||
def __init__(self, command, timeout=60, _dumb=True):
|
||||
env = os.environ.copy()
|
||||
env['TERM'] = 'dumb'
|
||||
if _dumb:
|
||||
env['TERM'] = 'dumb'
|
||||
else:
|
||||
env['TERM'] = 'xterm'
|
||||
env['NO_COLOR'] = '1'
|
||||
super().__init__(command, timeout=timeout, encoding='utf-8', env=env)
|
||||
|
||||
def __del__(self):
|
||||
@@ -122,19 +126,23 @@ def test_bare_console_wrap_floats():
|
||||
assert c.expect_exact("mpf('2.0')\r\n>>> ") == 0
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 13),
|
||||
reason="XXX: uses new REPL")
|
||||
def test_bare_console_pretty():
|
||||
c = Console(f'{sys.executable} -m mpmath --simple-prompt --no-ipython --prec 100 '
|
||||
"--colors 'NoColor'")
|
||||
"--colors 'NoColor'", _dumb=False)
|
||||
|
||||
assert c.expect_exact('>>> ') == 0
|
||||
assert c.expect('>>> ') == 0
|
||||
assert c.send("10.9\r\n") == 6
|
||||
assert c.expect_exact("10.899999999999999999999999999995\r\n>>> ") == 0
|
||||
assert c.expect("10.899999999999999999999999999995") == 0
|
||||
assert c.send("def f():\r\n x = ?\r\n\r\n") == 21
|
||||
assert c.expect('SyntaxError:') == 0
|
||||
assert c.send('def f():\r\n x = 1.1\n return x + 1\n\r\n\n') == 42
|
||||
assert c.expect_exact('>>> ') == 0
|
||||
assert c.send('def f():\r\n return 1.1\r\n\r\n') == 26
|
||||
assert c.expect('>>> ') == 0
|
||||
assert c.send("f()\r\n") == 5
|
||||
assert c.expect_exact('2.0999999999999999999999999999987\r\n>>> ') == 0
|
||||
assert c.expect('1.1000000000000000000000000000003') == 0
|
||||
assert c.send("a = 2.1; a\r\n") == 12
|
||||
assert c.expect('2.0999999999999999999999999999987') == 0
|
||||
|
||||
|
||||
def test_mpmath_version():
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ Documentation = 'http://mpmath.org/doc/current/'
|
||||
[project.optional-dependencies]
|
||||
tests = ['pytest>=6', 'numpy', 'packaging', 'pytest-timeout',
|
||||
'matplotlib', 'pexpect', 'ipython', 'hypothesis']
|
||||
develop = ['mpmath[tests]', 'flake518>=1.5', 'pytest-cov', 'wheel', 'build']
|
||||
develop = ['mpmath[tests]', 'flake518>=1.5', 'pytest-cov<7', 'wheel', 'build']
|
||||
gmpy2 = ['gmpy2>=2.3.0a1']
|
||||
gmpy = ['mpmath[gmpy2]']
|
||||
gmp = ['python-gmp>=0.4']
|
||||
|
||||
Reference in New Issue
Block a user