def expect_import_error(self, mod_name): try: run_module(mod_name) except ImportError: pass else: assert false, "Expected import error for " + mod_name
def _check_module(self, depth): pkg_dir, mod_fname, mod_name = ( self._make_pkg("x=1\n", depth)) try: if verbose: print "Running from source:", mod_name d1 = run_module(mod_name) # Read from source __import__(mod_name) os.remove(mod_fname) if verbose: print "Running from compiled:", mod_name d2 = run_module(mod_name) # Read from bytecode finally: self._del_pkg(pkg_dir, depth, mod_name) assert d1["x"] == d2["x"] == 1 if verbose: print "Module executed successfully"
def _check_module(self, depth): pkg_dir, mod_fname, mod_name = (self._make_pkg("x=1\n", depth)) try: if verbose: print "Running from source:", mod_name d1 = run_module(mod_name) # Read from source __import__(mod_name) os.remove(mod_fname) #--- the block below is to check that "imp.find_module" #--- manages to import the .pyc file alone. We don't #--- support it in PyPy in the default configuration. return if verbose: print "Running from compiled:", mod_name d2 = run_module(mod_name) # Read from bytecode finally: self._del_pkg(pkg_dir, depth, mod_name) assert d1["x"] == d2["x"] == 1 if verbose: print "Module executed successfully"
def _check_module(self, depth): pkg_dir, mod_fname, mod_name = ( self._make_pkg("x=1\n", depth)) try: if verbose: print "Running from source:", mod_name d1 = run_module(mod_name) # Read from source __import__(mod_name) os.remove(mod_fname) #--- the block below is to check that "imp.find_module" #--- manages to import the .pyc file alone. We don't #--- support it in PyPy in the default configuration. return if verbose: print "Running from compiled:", mod_name d2 = run_module(mod_name) # Read from bytecode finally: self._del_pkg(pkg_dir, depth, mod_name) assert d1["x"] == d2["x"] == 1 if verbose: print "Module executed successfully"
def test_library_module(self): run_module("pypy.lib.runpy")