Author: mattip <[email protected]>
Branch:
Changeset: r71500:4c48d672074a
Date: 2014-05-14 03:04 +0300
http://bitbucket.org/pypy/pypy/changeset/4c48d672074a/
Log: redo irc_topic and tests
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -671,8 +671,9 @@
if inspect_requested():
try:
from _pypy_interact import interactive_console
- irc_topic = sys.version_info[3] != 'final' or (
- readenv and os.getenv('PYPY_IRC_TOPIC'))
+ pypy_version_info = getattr(sys, 'pypy_version_info',
sys.version_info)
+ irc_topic = pypy_version_info[3] != 'final' or (
+ readenv and os.getenv('PYPY_IRC_TOPIC'))
success = run_toplevel(interactive_console, mainmodule,
quiet=not irc_topic)
except SystemExit, e:
diff --git a/pypy/interpreter/test/test_app_main.py
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -7,12 +7,8 @@
from rpython.tool.udir import udir
from contextlib import contextmanager
from pypy.conftest import pypydir
-from pypy.module.sys.version import PYPY_VERSION
from lib_pypy._pypy_interact import irc_header
-is_release = PYPY_VERSION[3] == "final"
-
-
banner = sys.version.splitlines()[0]
app_main = os.path.join(os.path.realpath(os.path.dirname(__file__)),
os.pardir, 'app_main.py')
@@ -246,10 +242,6 @@
child = self.spawn([])
child.expect('Python ') # banner
child.expect('>>> ') # prompt
- if is_release:
- assert irc_header not in child.before
- else:
- assert irc_header in child.before
child.sendline('[6*7]')
child.expect(re.escape('[42]'))
child.sendline('def f(x):')
@@ -269,11 +261,22 @@
child.sendline("'' in sys.path")
child.expect("True")
- def test_irc_topic(self, monkeypatch):
+ def test_yes_irc_topic(self, monkeypatch):
monkeypatch.setenv('PYPY_IRC_TOPIC', '1')
child = self.spawn([])
child.expect(irc_header) # banner
+ def test_maybe_irc_topic(self):
+ import sys
+ pypy_version_info = getattr(sys, 'pypy_version_info', sys.version_info)
+ irc_topic = pypy_version_info[3] != 'final'
+ child = self.spawn([])
+ child.expect('>>>') # banner
+ if irc_topic:
+ assert irc_header in child.before
+ else:
+ assert irc_header not in child.before
+
def test_help(self):
# test that -h prints the usage, including the name of the executable
# which should be /full/path/to/app_main.py in this case
@@ -934,6 +937,7 @@
# ----------------------------------------
from pypy.module.sys.version import CPYTHON_VERSION, PYPY_VERSION
cpy_ver = '%d.%d' % CPYTHON_VERSION[:2]
+ from lib_pypy._pypy_interact import irc_header
goal_dir = os.path.dirname(app_main)
# build a directory hierarchy like which contains both bin/pypy-c and
@@ -953,6 +957,7 @@
self.w_fake_exe = self.space.wrap(str(fake_exe))
self.w_expected_path = self.space.wrap(expected_path)
self.w_trunkdir = self.space.wrap(os.path.dirname(pypydir))
+ self.w_is_release = self.space.wrap(PYPY_VERSION[3] == "final")
self.w_tmp_dir = self.space.wrap(tmp_dir)
@@ -1022,3 +1027,4 @@
# assert it did not crash
finally:
sys.path[:] = old_sys_path
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit