This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bignose
Recipients bignose, ethan.furman
Date 2016-02-16.05:53:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455602033.68.0.493197345296.issue26362@psf.upfronthosting.co.za>
In-reply-to
Content
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)

With a supported standard library API for this – ‘tempfile.makepath’
for example – the generation of the filesystem path would change from
four separate function calls::

    names = tempfile._get_candidate_names()
    fake_file_path = os.path.join(tempfile.gettempdir(), names.next())

to a simple function call::

    fake_file_path = tempfile.makepath()

and have the benefit of not reaching in to a private API.
History
Date User Action Args
2016-02-16 05:53:53bignosesetrecipients: + bignose, ethan.furman
2016-02-16 05:53:53bignosesetmessageid: <1455602033.68.0.493197345296.issue26362@psf.upfronthosting.co.za>
2016-02-16 05:53:53bignoselinkissue26362 messages
2016-02-16 05:53:53bignosecreate