def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) assert repr(path).endswith('[fake]') foo_txt = path.join('foo.txt') assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') assert f.name == os.devnull
def test_nullpath(tmpdir): path = NullPyPathLocal(tmpdir) assert repr(path).endswith('[fake]') foo_txt = path.join('foo.txt') assert isinstance(foo_txt, NullPyPathLocal) # f = foo_txt.open('w') assert f.name == os.devnull
def generate_source(self, db=None, defines={}, exe_name=None): assert self.c_source_filename is None if db is None: db = self.build_database() pf = self.getentrypointptr() if self.modulename is None: self.modulename = uniquemodulename('testing') modulename = self.modulename targetdir = udir.ensure(modulename, dir=1) if self.config.translation.dont_write_c_files: targetdir = NullPyPathLocal(targetdir) self.targetdir = targetdir defines = defines.copy() if self.config.translation.countmallocs: defines['COUNT_OP_MALLOCS'] = 1 if self.config.translation.countfieldaccess: defines['RPY_COUNT_FIELDACCESS'] = 1 if self.config.translation.sandbox: defines['RPY_SANDBOXED'] = 1 if self.config.translation.reverse_debugger: defines['RPY_REVERSE_DEBUGGER'] = 1 if self.config.translation.rpython_translate: defines['RPY_TRANSLATE'] = 1 if CBuilder.have___thread is None: CBuilder.have___thread = self.translator.platform.check___thread() if not self.standalone: assert not self.config.translation.instrument else: defines['PYPY_STANDALONE'] = db.get(pf) if self.config.translation.instrument: defines['PYPY_INSTRUMENT'] = 1 if CBuilder.have___thread: if not self.config.translation.no__thread: defines['USE___THREAD'] = 1 if self.config.translation.shared: defines['PYPY_MAIN_FUNCTION'] = "pypy_main_startup" self.eci, cfile, extra, headers_to_precompile = \ gen_source(db, modulename, targetdir, self.eci, defines=defines, split=self.split) self.c_source_filename = py.path.local(cfile) self.extrafiles = self.eventually_copy(extra) self.gen_makefile(targetdir, exe_name=exe_name, headers_to_precompile=headers_to_precompile) return cfile