Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102992
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Make a unique filesystem path, without creating the file |
| Date | Tue, 16 Feb 2016 08:35:40 +0000 |
| Lines | 40 |
| Message-ID | <mailman.156.1455611742.22075.python-list@python.org> (permalink) |
| References | <85egce6a8a.fsf@benfinney.id.au> <20160215230539.GA42677@cskk.homeip.net> <851t8d42rt.fsf@benfinney.id.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de JwP13tiGF0fZ3WktizIfowuAD44CBfV56d7h2qjOOKyA== |
| Return-Path | <oscar.j.benjamin@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.028 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; '"""': 0.05; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; 'tempfile': 0.09; 'def': 0.13; '2016': 0.16; 'cc:name:python list': 0.16; 'function?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'simpson': 0.16; 'wrote:': 0.16; 'case.': 0.18; '>': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'feb': 0.23; 'import': 0.24; 'patch': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'example': 0.26; 'skip:t 40': 0.27; 'message- id:@mail.gmail.com': 0.27; 'name?': 0.29; 'asked': 0.29; "i'm": 0.30; 'skip:s 30': 0.31; 'open': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'configured': 0.35; 'skip:i 20': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'received:209': 0.38; 'names': 0.38; 'skip:p 20': 0.38; 'why': 0.39; 'subject:the': 0.39; 'care': 0.60; 'your': 0.60; 'real': 0.62; 'skip:n 10': 0.62; 'skip:w 30': 0.64; 'cameron': 0.66; 'sit': 0.66; 'watching': 0.72; 'oscar': 0.84; 'to:none': 0.91; 'alone.': 0.91; 'subject:Make': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=vx2DMExLWEYlwltuRj5xZR6Ax5vriP3Vn5j4XvIFEMg=; b=X7lbZ12B7EYO615KJ6sjzvn7ReQCovtXr9BgNYmNo9ItQzzQJAG5TWAnm5z7TESvf5 JBYIKY7S8Ry3EDJ9wbntNDQkvbnkV4rf8eWpwhr2L2FgqL5HShmIxn7goGyWQnVOSvGj SYH7sc2L5SVKYfvITRa52bL7eKb6Y9qDI7ZqiB2FvPYFNSb/mlHCsCYyaQjZoLRnxN/w JkYU9khzgJRSU313RMKSkKS3ecY6RBAkzqDU82kjol0aQebJrQy6hjZp1vwi7lOIDa2i J7hV607Ss6fvqJXvQBlvWmgnHJy8G5hGdHlS8+02QM8pCimWSFh4VxFgCqOaaXbOBRN6 rOQw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=vx2DMExLWEYlwltuRj5xZR6Ax5vriP3Vn5j4XvIFEMg=; b=OprwHV+ys8SDsIMGP/y25VRRQttBRqz93R4O53YLQF3dZci81uXVfQ36nCF6uADDjN DZvmuMFPDGjbNg7gt82lOao7hzo8zFnPR4HRUbLusxYBCInG0wbZpuiEzHPAe+illfIm sTVnl0AyXvPwmW4QOd9Dx512A6qwYZMRe+/J4eKtGJd+f4HRhwu4tt8ZB+ZZP3Nnq2lt tQ0KPe9jJROa07dJK9bTyi2C5FIuLV+/1jTVsnxN1PRBek0zxbXFdWf/pEwjbOADMJbA p5Oe9o4yMWo/KQZZXyRFI+RiCc/ih+A2/OqhODdaj3tkHgLH1CsYlNDQ42I88bbMndRb 7vtQ== |
| X-Gm-Message-State | AG10YOTvPkMa+tBQTwPTRGREnmqrDOdBqg2yVn0oeZnyzSP8kc9Cy/fXl9i5AUyZK+LdbwHUN292QnxMue9QQA== |
| X-Received | by 10.112.235.71 with SMTP id uk7mr8756233lbc.39.1455611740515; Tue, 16 Feb 2016 00:35:40 -0800 (PST) |
| In-Reply-To | <851t8d42rt.fsf@benfinney.id.au> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21rc2 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102992 |
Show key headers only | View raw
On 16 Feb 2016 05:57, "Ben Finney" <ben+python@benfinney.id.au> wrote:
>
> Cameron Simpson <cs@zip.com.au> writes:
>
> > I've been watching this for a few days, and am struggling to
> > understand your use case.
>
> Yes, you're not alone. This surprises me, which is why I'm persisting.
>
> > Can you elaborate with a concrete example and its purpose which would
> > work with a mktemp-ish official function?
>
> An example::
>
> import io
> import tempfile
> names = tempfile._get_candidate_names()
>
> def test_frobnicates_configured_spungfile():
> """ ‘foo’ should frobnicate the configured spungfile. """
>
> fake_file_path = os.path.join(tempfile.gettempdir(), names.next())
> fake_file = io.BytesIO("Lorem ipsum, dolor sit
amet".encode("utf-8"))
>
> patch_builtins_open(
> when_accessing_path=fake_file_path,
> provide_file=fake_file)
>
> system_under_test.config.spungfile_path = fake_file_path
> system_under_test.foo()
> assert_correctly_frobnicated(fake_file)
If you're going to patch open to return a fake file when asked to open
fake_file_path why do you care whether there is a real file of that name?
--
Oscar
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Make a unique filesystem path, without creating the file Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-02-16 08:35 +0000
csiph-web