Commit f1d68aa0 authored by Jason Madden's avatar Jason Madden

Fix tests that use relative imports.

parent e0a7c267
......@@ -415,12 +415,7 @@ def _setup_environ(debug=False):
# Python 3.6
os.environ['PYTHONMALLOC'] = 'debug'
if (sys.version_info == (3, 7, 0, 'beta', 2)
and (os.environ.get("PYTHONDEVMODE") or os.environ.get('PYTHONMALLOC'))):
# See https://twitter.com/ossmkitty/status/970693025130311680
# https://bugs.python.org/issue33005
os.environ.pop('PYTHONDEVMODE', None)
os.environ.pop('PYTHONMALLOC', None)
def main():
import argparse
......@@ -485,6 +480,10 @@ def main():
# XXX: Add a way to force these.
print("Not running tests on pypy with c-ares; not a supported configuration")
return
if options.package:
# Put this directory on the path so relative imports work.
package_dir = _dir_from_package_name(options.package)
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', "") + os.pathsep + package_dir
run_many(tests, configured_failing_tests=FAILING_TESTS, failfast=options.failfast, quiet=options.quiet)
......
......@@ -6,7 +6,7 @@ import subprocess
if sys.argv[1:] == []:
os.environ['GEVENT_BACKEND'] = 'select'
popen = subprocess.Popen([sys.executable, 'test__environ.py', '1'])
popen = subprocess.Popen([sys.executable, __file__, '1'])
assert popen.wait() == 0, popen.poll()
else:
hub = gevent.get_hub()
......
......@@ -10,6 +10,13 @@ from subprocess import PIPE
class TestRun(unittest.TestCase):
maxDiff = None
def setUp(self):
self.cwd = os.getcwd()
os.chdir(os.path.dirname(__file__))
def tearDown(self):
os.chdir(self.cwd)
def _run(self, script):
env = os.environ.copy()
env['PYTHONWARNINGS'] = 'ignore'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment